• Resolved Leon

    (@llpvk)


    Hello there,

    today, I discovered two strange problems on the archive page of my shop, both related to variable products:

    1. All variable products are displayed as “out of stock”, even though they are indeed stocked. (On the single product pages, the stock status is displayed correctly.)

    2. The price (range)s of all variable products have disappeared from the archive page.

    The shop in question: https://caffebarbera.de/shop/

    (Quick Translation: “In den Warenkorb” = “Add to Cart”, “zurzeit vergriffen” = “temporarily out of stock”)

    I am using WordPress v4.6, WooCommerce v2.6.4 and the (untouched!) theme “TwentyTwelve” v2.1 together with an accompanying child theme.

    The following customizing has been done in the functions.php of my child theme:

    /* WooCommerce: minimaler Preis statt Preisspanne */
    
    add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);
    function custom_variation_price( $price, $product ) {
    $price = '';
    if ( !$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) $price .= '<span class="from">' . _x('ab', 'min_price', 'woocommerce') . ' </span>';
    $price .= woocommerce_price($product->min_variation_price);
    return $price;
    }
    
    /* Zeige-Details-Button */
    
    add_action( 'woocommerce_after_shop_loop_item', 'my_woocommerce_template_loop_add_to_cart', 10 );
    
    function my_woocommerce_template_loop_add_to_cart() {
        echo '<form action="' . get_permalink() . '" method="get">
                <button type="submit" class="button add_to_cart_button product_type_simple">Details</button>
              </form>';
    }
    
    /* WooCommerce: ähnliche Produkte ausblenden */
    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
    
    /* Display x products per page */
    add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 30;' ), 20 );
    
    /* Produkt-Archiv: zurzeit leider nicht vorrätig */
    add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_stock', 10);
    function woocommerce_template_loop_stock() {
    	global $product;
     		if ( ! $product->managing_stock() && ! $product->is_in_stock() )
     		echo '<p class="stock out-of-stock">z. Zt. leider nicht vorrätig</p>';
    }

    Do you have any ideas/solutions? Thank you in advance!

    Best
    Leon

    https://ww.wp.xz.cn/plugins/woocommerce/

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

    (@icaleb)

    Automattic Happiness Engineer

    First, it’s best to find out what is conflicting and causing these issues.

    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.

    You may need to clear your transients between testing. You can do this at WooCommerce > System Status > Tools.

    Thread Starter Leon

    (@llpvk)

    Hi Caleb, thank you very much for your response!

    Unfortunately, the following attempts weren’t successful:
    – Switching the theme (I tried “Twenty Sixteen”)
    – Downgrading to WordPress 4.5.3
    – Commenting out the manually added code in my functions.php

    Or is there maybe something wrong in terms of handling the stock statūs of the variable products? My setting: “Manage stock” is activated for the “overall” products as well as for their variations.

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    You may need to re-save the variable product after disabling everything and switching theme. They could have messed up the data.

    Or is there maybe something wrong in terms of handling the stock statūs of the variable products? My setting: “Manage stock” is activated for the “overall” products as well as for their variations.

    If you are managing stock at the variation level, then you should uncheck that option at the product level 🙂

    Thread Starter Leon

    (@llpvk)

    You may need to re-save the variable product

    Well, this actually solved the problem. Caleb, you made my day. Thanks a million!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Archive: Problems with Variable Products’ is closed to new replies.