• Using:
    – wordpress 4.6
    – woocommerce 2.6.4

    This error has been bothering me for a long time and now I figured out its cause: if you choose a variable product to buy, woocommerce does not consider whatever cross sell you setup.

    If it is a simple product cross sell shows up nicely; if it is a variable product, nothing shows up.

    Why is that?

    https://www.ads-software.com/plugins/woocommerce/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Cross sells are working for me w/ variable products.

    Try temporarily switching back to the WordPress Twenty Sixteen Theme, or Storefront, and disable all plugins except for WooCommerce. If that resolves the issue, then slowly re-enable features until you find the one that’s causing the conflict.

    Thread Starter Claudio Longato Jr

    (@clongatojr)

    I′ve tried that and still nothing.

    The point is the function that is supposed to retrieve cross sells doesn′t find any, even though there is a cross sell set for the variation′s ‘parent’ product.

    Thread Starter Claudio Longato Jr

    (@clongatojr)

    Spotted the problem: get_cross_sells does not use the ‘parent id’ of the variation to check for cross sells.

    I′ve change the function from this:

    foreach ( $this->get_cart() as $cart_item_key => $values ) {
    if ( $values[‘quantity’] > 0 ) {
    $cross_sells = array_merge( $values[‘data’]->get_cross_sells(), $cross_sells );
    $in_cart[] = $values[‘product_id’];
    }
    }

    to this:

    foreach ( $this->get_cart() as $cart_item_key => $values ) {
    if ( $values[‘quantity’] > 0 ) {
    $item_cross_sells = ((int)$values[‘variation_id’] > 0) ? $values[‘data’]->parent->get_cross_sells() : $values[‘data’]->get_cross_sells();
    $cross_sells = array_merge( $item_cross_sells, $cross_sells );
    $in_cart[] = $values[‘product_id’];
    }
    }

    And now I have my cross sells showing up correctly because now the function is aware of the type of product.

    Is this something that should be changed in woocommerce?

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Odd, where these products imported? Maybe your variation has a meta field ‘crosssell_ids’ – because it should inherit from parent as it stands.

    Thread Starter Claudio Longato Jr

    (@clongatojr)

    Yes, they were imported using Product CSV Import. Now I have exported all variations including hidden meta fields and there are two meta field related to cross sells: meta:_crosssell_ids and meta:_crosssell_skus.

    How can I get rid of those columns and use the ‘default’ of woocommerce?

    Thread Starter Claudio Longato Jr

    (@clongatojr)

    Further inspection in the database showed that cross sells are not being stored. I manually added them in the database (copied ‘upsells’ syntax) and now cross sells are showing up, but I′m with a new question: why are cross sells not being saved in the database? The form field is populated correctly in the edit page.

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    I can’t replicate that either. My values are being saved on variable products. Have you edited anything else in the core files? Try replacing your woocommerce folder with a newly downloadable version.

    Also I suspect the original import could have something to do with this.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Cross Sell Error – not showing’ is closed to new replies.