• Resolved dadim

    (@dadim)


    In version 7.1.7 the shipping fields are not copied to the order.
    In the previous version( ver. 5) I had inserted this code in the fuctions and it worked. Now it no longer works

    add_action(‘woocommerce_email_after_order_table’, ‘wooccm_order_receipt_checkout_details’, 10, 3);
    
    function wooccm_order_receipt_checkout_details($order, $sent_to_admin, $plain_text = ”) {
    
    if (class_exists(‘WOOCCM’)) {
    
    $billing_defaults = WOOCCM()->billing->get_defaults();
    $shipping_defaults = WOOCCM()->shipping->get_defaults();
    $additional_defaults = WOOCCM()->additional->get_defaults();
    
    $billing = WOOCCM()->billing->get_fields();
    $shipping = WOOCCM()->shipping->get_fields();
    $additional = WOOCCM()->additional->get_fields();
    
    if (!empty($billing)) {
    
    foreach ($billing as $btn) {
    
    if (!in_array($btn[‘name’], $billing_defaults)) {
    
    if (( get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true) !== ” ) && !empty($btn[‘label’]) && $btn[‘type’] !== ‘heading’ && $btn[‘type’] !== ‘multiselect’ && $btn[‘type’] !== ‘file’ && $btn[‘type’] !== ‘multicheckbox’ ) { echo $btn[‘label’] . ‘: ‘ . nl2br(get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true));
    echo “
    ”;
    } elseif (
    !empty($btn[‘label’]) &&
    $btn[‘type’] == ‘heading’ &&
    $btn[‘type’] !== ‘multiselect’ &&
    $btn[‘type’] !== ‘file’ &&
    $btn[‘type’] !== ‘multicheckbox’
    ) {
    echo $btn[‘label’];
    echo “
    ”;
    } elseif (
    ( get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true) !== ” ) && !empty($btn[‘label’]) && $btn[‘type’] !== ‘heading’ && $btn[‘type’] !== ‘file’ && ( $btn[‘type’] == ‘multiselect’ || $btn[‘type’] == ‘multicheckbox’ ) ) { $value = get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true);
    $strings = maybe_unserialize($value);
    echo $btn[‘label’] . ‘: ‘;
    if (!empty($strings)) {
    if (is_array($strings)) {
    $iww = 0;
    $len = count($strings);
    foreach ($strings as $key) {
    if ($iww == $len – 1) {
    echo $key;
    } else {
    echo $key . ‘, ‘;
    }
    $iww++;
    }
    } else {
    echo $strings;
    }
    } else {
    echo ‘-‘;
    }
    echo “
    ”;
    }
    }
    }
    }
    
    if (!empty($shipping)) {
    
    foreach ($shipping as $btn) {
    
    if (!in_array($btn[‘name’], $shipping_defaults)) {
    
    if (( get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true) !== ” ) && !empty($btn[‘label’]) && $btn[‘type’] !== ‘heading’ && $btn[‘type’] !== ‘multiselect’ && $btn[‘type’] !== ‘file’ && $btn[‘type’] !== ‘multicheckbox’ ) { echo $btn[‘label’] . ‘: ‘ . nl2br(get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true));
    echo “
    ”;
    } elseif (
    !empty($btn[‘label’]) &&
    $btn[‘type’] == ‘heading’ &&
    $btn[‘type’] !== ‘multiselect’ &&
    $btn[‘type’] !== ‘file’ &&
    $btn[‘type’] !== ‘multicheckbox’
    ) {
    echo $btn[‘label’];
    echo “
    ”;
    } elseif (
    ( get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true) !== ” ) && !empty($btn[‘label’]) && $btn[‘type’] !== ‘heading’ && $btn[‘type’] !== ‘file’ && ( $btn[‘type’] == ‘multiselect’ || $btn[‘type’] == ‘multicheckbox’ ) ) { $value = get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true);
    $strings = maybe_unserialize($value);
    echo $btn[‘label’] . ‘: ‘;
    if (!empty($strings)) {
    if (is_array($strings)) {
    $iww = 0;
    $len = count($strings);
    foreach ($strings as $key) {
    if ($iww == $len – 1) {
    echo $key;
    } else {
    echo $key . ‘, ‘;
    }
    $iww++;
    }
    } else {
    echo $strings;
    }
    } else {
    echo ‘-‘;
    }
    echo “
    ”;
    }
    }
    }
    }
    
    if (!empty($additional)) {
    
    foreach ($additional as $btn) {
    
    if (!in_array($btn[‘name’], $additional_defaults)) {
    
    if (( get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true) !== ” ) && !empty($btn[‘label’]) && $btn[‘type’] !== ‘heading’ && $btn[‘type’] !== ‘multiselect’ && $btn[‘type’] !== ‘file’ && $btn[‘type’] !== ‘multicheckbox’ ) { echo $btn[‘label’] . ‘: ‘ . nl2br(get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true));
    echo “
    ”;
    } elseif (
    !empty($btn[‘label’]) &&
    $btn[‘type’] == ‘heading’ &&
    $btn[‘type’] !== ‘multiselect’ &&
    $btn[‘type’] !== ‘file’ &&
    $btn[‘type’] !== ‘multicheckbox’
    ) {
    echo $btn[‘label’];
    echo “
    ”;
    } elseif (
    ( get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true) !== ” ) && !empty($btn[‘label’]) && $btn[‘type’] !== ‘heading’ && $btn[‘type’] !== ‘file’ && ( $btn[‘type’] == ‘multiselect’ || $btn[‘type’] == ‘multicheckbox’ ) ) { $value = get_post_meta($order->get_id(), sprintf(‘%s’, $btn[‘key’]), true);
    $strings = maybe_unserialize($value);
    echo $btn[‘label’] . ‘: ‘;
    if (!empty($strings)) {
    if (is_array($strings)) {
    $iww = 0;
    $len = count($strings);
    foreach ($strings as $key) {
    if ($iww == $len – 1) {
    echo $key;
    } else {
    echo $key . ‘, ‘;
    }
    $iww++;
    }
    } else {
    echo $strings;
    }
    } else {
    echo ‘-‘;
    }
    echo “
    ”;
    }
    }
    }
    }
    }
    }

    How can it be solved?

    • This topic was modified 1 year, 8 months ago by dadim.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Additional fields in the print’ is closed to new replies.