• Resolved btaadmin

    (@btaadmin)


    I believe there’s a small bug where In Stock message is not displayed upon activation of this plugin. I traced the issue to a test if (!$product->managing_stock() || !$product->is_on_backorder(1)), which should be &&, as per below.

    public function change_backorder_message($text, $product)
      {
        /**
         * Edits the backorder message to include a custom message or a default
         * @param string $text
         * @param WC_Product $product
         */
    
        if (!$product->managing_stock() && !$product->is_on_backorder(1)) {
          return;
        }
    
        $backorder_message = get_post_meta(
          $product->get_id(),
          "_backorder_message",
          true
        );
    
        return !empty($backorder_message)
          ? $backorder_message
          : $text;
      }
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author gregbast1994

    (@gregbast1994)

    Thanks, I updated the plugin with your suggested fix.

    I appreciate your help. ??

    Thread Starter btaadmin

    (@btaadmin)

    Hey @gregbast1994 unfortunately, it still doesn’t work correctly and my bad for not updating my post.

    We need to satisfy the following scenario.

    1) the custom back order message shows, if defined and product is out of stock.

    2) if product/product variant is in stock it doesn’t show the custom message even if left defined. Simply, the custom message should effectively work to override the back order message but not the reason for the message.

    3) if product is in stock it shows the default in stock message.

    Unfortunately my amended of statement doesn’t come close to solving that. I’ll have a think about it. One of the issues I think is product variants and checking their stock status.

    Plugin Author gregbast1994

    (@gregbast1994)

    Thank you for your detailed response. You are right, it should not alter the stock text if the item is not out of stock.

    I’ve updated the code, please let me know if i’ve fixed your issue.

    Thread Starter btaadmin

    (@btaadmin)

    I’ve just re-activated the plugin. All seems to be behaving well. Great job! Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘In Stock message not shown’ is closed to new replies.