whumphreys
Forum Replies Created
Viewing 6 replies - 1 through 6 (of 6 total)
-
this is exactly what i was looking for, to set seat unlimited
where exactly will i do this
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 4 months ago by whumphreys.
still have the same issue, I do not know where to start from to fix this, can you give a hint in file is responsible for it
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
no, all i have is cash on delivery nothing else, my main issue is that when i go to checkout page, it doesnt add up the right prices and there is no description as what was selected, meaning it just has some ramdom price and not event telling where is coming from
Viewing 6 replies - 1 through 6 (of 6 total)