Support » Plugin: WooCommerce Variable Product Add-Ons » v0.1.2 problem with addon price not being added to total

  • Hi – I’m developing a site on a virtual machine on my PC (so can’t easily demonstrate the problem to you!), but I’ve started encountering a problem with variable products I’ve started adding in the last few days whereby I can select the addon, the addon price is displayed correctly in ‘Options total’. The ‘Grand total’ is correct, but after I hit ‘Add To Basket’ and check my shopping cart, the addon price hasn’t been added to the product in the cart.
    If I disable ‘WooCommerce Variable Product Add-Ons’ it works absolutely fine.

    The strange thing is that products I added a few days ago work perfectly OK, and it’s only recently-added ones with the issue. I’ve checked all the settings for the newer ones and everything looks OK. I can’t recall an update to ‘WooCommerce Variable Product Add-Ons’ in the last week or so? I’m pretty sure I started off with v0.1.2.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’ve been doing a bit of rudimentary debugging.
    The products which work (addons are added to variation price) appear to be ones which don’t have an entry in wp_postmeta (meta_key = ‘_variable_add_ons’). It’s likely these product variations/addons were added before I installed the WooCommerce Variable Product Add-ons plugin, (hence why they’re working?!).

    The broken ones (where addon price is not being added to variation price in the cart) *do* have an entry in wp_postmeta but meta_value is set to ‘no’.
    Here’s an example of one which is ‘broken’:
    +———+———+——————-+————+
    | meta_id | post_id | meta_key | meta_value |
    +———+———+——————-+————+
    | 5370 | 573 | _variable_add_ons | no |
    +———+———+——————-+————+

    The ‘no’ value means the $cart_item_data array gets set to ” in woocommerce_add_cart_item_data().
    Presumably with the ‘working’ ones where there’s no _variable_add_ons entry in wp_postmeta mean $cart_item_data is being left untouched – just check, yes this appears to be the case.

    Am I right in thinking the logic in:

    function woocommerce_add_cart_item_data( $cart_item_data, $product_id, $variation_id )
    {
    $add_ons = get_post_meta( $variation_id, ‘_variable_add_ons’, true );
    if( $add_ons == ‘no’ ) $cart_item_data = ”;
    return $cart_item_data;
    }

    might be wrong? Changing if( $add_ons == ‘no’ ) to if( $add_ons == ‘yes’ ) appears to work!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘v0.1.2 problem with addon price not being added to total’ is closed to new replies.