• whumphreys

    (@whumphreys)


    nice plugin, but why is it Coach Type type not showing up on checkout page, or in the cart data, and also where all bus are listed on the admin area it appears blank as well, is this a settings issue

    • This topic was modified 4 months ago by whumphreys.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Dear whumphreys,

    I hope you got the solution. if you still facing this problem, please let us know here or contact our support team.

    Thank you

    Kayes

    Thread Starter whumphreys

    (@whumphreys)

    Thanks i did, had custom script to achieved it, if anyone is interested in it i can post here, i do not know ur policies thats why i did not pasted here

    Please share your code here.

    Thank you

    Thread Starter whumphreys

    (@whumphreys)

    add_filter('woocommerce_add_cart_item_data', 'add_custom_cart_item_data', 10, 3);
    function add_custom_cart_item_data($cart_item_data, $product_id, $variation_id) {
    if (isset($_POST['wbtm_bus_category'])) {
    $cart_item_data['wbtm_bus_category'] = sanitize_text_field($_POST['wbtm_bus_category']);
    }
    return $cart_item_data;
    }

    add_filter('woocommerce_get_item_data', 'display_custom_data_in_cart', 10, 2);
    function display_custom_data_in_cart($item_data, $cart_item) {
    if (isset($cart_item['wbtm_bus_category'])) {
    $item_data[] = array(
    'key' => __('Type', 'textdomain'),
    'value' => wc_clean($cart_item['wbtm_bus_category']),
    );
    }
    return $item_data;
    }

    add_action('woocommerce_add_order_item_meta', 'save_custom_data_to_order', 10, 2);
    function save_custom_data_to_order($item_id, $values) {
    if (isset($values['wbtm_bus_category'])) {
    wc_add_order_item_meta($item_id, 'Transporte', $values['wbtm_bus_category']);
    }
    }

    add_filter('woocommerce_order_item_display_meta_key', 'custom_order_item_display_meta_key');
    function custom_order_item_display_meta_key($display_key) {
    if ($display_key == 'Type') {
    $display_key = __('Type', 'textdomain');
    }
    return $display_key;
    }

    add_filter('woocommerce_get_cart_item_from_session', 'get_custom_data_from_session', 20, 2);
    function get_custom_data_from_session($cart_item, $values) {
    if (isset($values['wbtm_bus_category'])) {
    $cart_item['wbtm_bus_category'] = $values['wbtm_bus_category'];
    }
    return $cart_item;
    }
    add_filter('woocommerce_email_order_meta_fields', 'custom_email_order_meta_fields', 10, 3);
    function custom_email_order_meta_fields($fields, $sent_to_admin, $order) {
    foreach ($order->get_items() as $item_id => $item) {
    if ($item->get_meta('Transporte')) {
    $fields['Type'] = array(
    'label' => __('Type', 'textdomain'),
    'value' => $item->get_meta('Transporte'),
    );
    }
    }
    return $fields;
    }

    I personally added the snippet in a plugin and not directly to theme files.

    Type is what I labeled it i know this data is visible everywhere , but feel free to change Type to wath ever siuts you.

    • This reply was modified 3 months, 3 weeks ago by whumphreys.
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.