Welcome to our Support Portal › Forums › WooCommerce Personalized Product Options Manager (PPOM) › Issue with bundled Products › Reply To: Issue with bundled Products
September 28, 2018 at 8:27 am
#9516
Participant
@nmedia, I think I have the solution, but please double check, test and see if I forgot any step in the process.
explanation:
Everytime we are working with items and PPOM, we need to check if the item is a bundled item.
We do this by checking if the class exists and check the item.
if ( class_exists('WC_Bundles') && wc_pb_is_bundled_cart_item( $product_id )) {
The actual changes:
file: woocommerce-product-addon\inc\woocommerce.php
function ppom_woocommerce_add_cart_item_data($cart, $product_id) {
if( ! isset($_POST['ppom']) ) return $cart;
if( ! $selected_meta_id = ppom_has_product_meta( $product_id ) ) {
return $cart;
}
// ADDED WC BUNDLES COMPATIBILITY
if ( class_exists('WC_Bundles') && wc_pb_is_bundled_cart_item( $product_id )) {
return $cart;
}
$ppom_settings = PPOM() -> get_product_meta ( $selected_meta_id );
if( empty($ppom_settings) ) return $cart;
// PPOM also saving cropped images under this filter.
$ppom_posted_fields = apply_filters('ppom_add_cart_item_data', $_POST['ppom'], $_POST);
$cart['ppom'] = $ppom_posted_fields;
// ppom_pa($_POST); exit;
return $cart;
}
function ppom_woocommerce_add_item_meta($item_meta, $cart_item) {
if( ! isset($cart_item['ppom']['fields']) ) return $item_meta;
// ADDED WC BUNDLES COMPATIBILITY
if ( class_exists('WC_Bundles') && wc_pb_is_bundled_cart_item( $cart_item )) {
return $item_meta;
}
$ppom_meta = ppom_make_meta_data( $cart_item );
// var_dump($ppom_meta);
foreach( $ppom_meta as $key => $meta ) {
$hidden = isset($meta['hidden']) ? $meta['hidden'] : false;
$display = isset($meta['display']) ? $meta['display'] : $meta['value'];
if( $key == 'ppom_has_quantities' ) $hidden = true;
// if( $key == 'ppom_has_files' ) $hidden = true;
if( isset( $meta['name']) ) {
$meta_val = $meta['value'];
if( apply_filters('ppom_show_option_price_cart', false) && isset($meta['price']) ) {
$meta_val .=' ('.wc_price($meta['price']).')';
}
$meta_key = stripslashes($meta['name']);
// WPML
$meta_key = ppom_wpml_translate($meta_key, 'PPOM');
$item_meta[] = array('name' => wp_strip_all_tags($meta_key), 'value' => $meta_val, 'hidden' => $hidden, 'display'=>$display);
} else {
$item_meta[] = array('name' => ($key), 'value' => $meta, 'hidden' => $hidden, 'display'=>$display);
}
}
return $item_meta;
}
function ppom_woocommerce_order_item_meta($item_id, $cart_item, $order_id) {
if ( ! isset ( $cart_item ['ppom']['fields'] )) {
return;
}
// ADDED WC BUNDLES COMPATIBILITY
if ( class_exists('WC_Bundles') && wc_pb_is_bundled_cart_item( $cart_item )) {
return;
}
$ppom_meta = ppom_make_meta_data( $cart_item, 'order' );
// var_dump($ppom_meta); exit;
foreach( $ppom_meta as $key => $meta ) {
ppom_add_order_item_meta($item_id, $key, $meta['value']);
}
}
I think by adding the check to these 3 functions we have solved the problem.