Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [CSS][PHP]Nie można wyświetlić merge tagu z dodanego custom field w woocommerce na poziomie podsumowania/maila, problem wewnątrz function.php z określeniem merge tag dla custom field
patkoz
post 19.08.2019, 12:33:37
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 19.08.2019

Ostrzeżenie: (0%)
-----


CEL:

-wyświetlać pole ['new_billing_field'] w mailu podsmowującym i nadać temu polu merge tag który wyświetli się w Kadence[wtyczka do maili] oraz w thank you page [ wtyczka nextmove lite ]
-wtyczki są mniej ważne - nie wiemy co robimy źle w dodawania/przypisisywaniu tego merge tag do pola ['new_billing_field'] - prośba o pomoc


//=====================================================
// show the custom meta data on the cart and checkout pages

add_filter( 'woocommerce_get_item_data', 'tp_get_custom_item_data', 10, 2 );
function tp_get_custom_item_data( $item_data, $cart_item ) {
if( isset( $cart_item['new_billing_field'] ) ) {
$item_data[] = array( 'name' => 'test', 'value' => $cart_item['new_billing_field'] );
}
return $item_data;
}

add_action('woocommerce_checkout_update_order_meta',function( $order_id, $posted ) {
$order = wc_get_order( $order_id );
$order->update_meta_data( 'new_billing_field', 'new_billing_field' );
$order->save();
} , 10, 2);
//=====================================
// Add custom field to order object



function cfwc_add_custom_data_to_order( $item, $cart_item_key, $values, $order ) {
foreach( $item as $cart_item_key=>$values ) {
if( isset( $values['new_billing_field'] ) ) {
$item->add_meta_data( __( 'test', 'cfwc' ), $values['new_billing_field'], true );
}
}
}
add_action( 'woocommerce_checkout_create_order_line_item', 'cfwc_add_custom_data_to_order', 10, 4 );


add_filter( 'kadence_woomail_order_body_text', 'custom_email_placeholder', 15, 5 );
function custom_email_placeholder( $body_text, $order, $sent_to_admin, $plain_text, $email ) {

$items = $order->get_items();

foreach ( $items as $item ) {

$product = wc_get_product( $item['new_billing_field'] );
}
if ( $order ) {
$body_text = str_replace( '{new_billing_field}', $product->get_name(), $body_text );
}
return $body_text;
}
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 16.04.2024 - 19:36