Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter brixxo

    (@brixxo)

    @softound Solutions:

    What if you just keep all code from the current stable release + add a check for simple products with unmanaged stock like below?

    – Status ‘instock’ & product in_stock message not set -> display global in_stock message
    – Status ‘instock’ & product in_stock message set -> display product in_stock message
    – Status ‘outofstock’ & product out_of_stock message not set -> display global out_of_stock message
    – Status ‘outofstock’ & product out_of_stock message set -> display product out_of_stock message

    <?php // Stock info
    //Get the product type
    $type = $product->get_type();
    //Get the stock status
    $stock_status = $product->get_stock_status();
    //Get manage stock
    $stock_managed = $product->get_manage_stock();
    ?>

    <?php if($type == ‘simple’ && $stock_managed == true): ?>
    <?php echo wc_get_stock_html( $product ); //From woocommerce/single-product/add-to-cart/simple.php ?>
    <?php endif; ?>
    <?php if($type == ‘simple’ && $stock_managed == false): ?>
    <?php if($stock_status == ‘instock’): ?>
    <p class=”stock in-stock in_stock_color”><!– Get the global or product in stock message here –></p>
    <?php endif; ?>
    <?php if($stock_status == ‘outofstock’): ?>
    <p class=”stock out-of-stock out_of_stock_color”><!– Get the global or product out of stock message here –></p>
    <?php endif; ?>
    <?php endif; ?>

    It’s getting the global or product in/out-of-stock message where I get stuck.

    Thread Starter brixxo

    (@brixxo)

    @skafte:

    Well, let’s say you have a variable product with 3 colors: Red (stock: 30 pcs), green (stock 50 pcs) and blue (stock: -10 pcs).

    If a customer selects red or green, the stock status should be ‘In stock’. If the customer selects blue, the stock status should be ‘Out of stock’.

    However, at the moment it’s always ‘In stock’, no matter what…

    Thread Starter brixxo

    (@brixxo)

    Just tested a bit more with variable products, but it seems stock status doesn’t update anymore. To be sure I tested with the Twenty Seventeen theme, not my custom theme.

    Variable product, stock is managed for variants -> https://www.screencast.com/t/NoTqHgGSeId
    https://www.screencast.com/t/JIMT90af

    Stock status doesn’t update on frontend, even if the variant is out of stock…

    Thread Starter brixxo

    (@brixxo)

    Hi @softound,

    Just tested your pre-release. Working great for me!

    Just one thing: I need the stock status to always display right above the add-to-cart button, in our case that is better for conversion.

    What would be the easiest way to achieve that? I guess that could be done through the theme functions.php?

    Or could you implement a setting to choose position? For example ‘below price’, ‘above add-to-cart button’ and ‘in secondary actions wrapper’.

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