• jmilez

    (@jmilez)


    Hi, I’ve been working with WC for a while and converted the New Badge plugin to show a “last one” badge instead, which had been working great. But just noticed my badges no longer work. My plugin still functions, such as the admin screen and to the point where it adds the action hook to add the badge style. But the page HTML only shows that the style sheet is getting loaded and my action never gets called (tried just adding a “echo” and nothing).

    Here is where I add the action, which is executed, but my action is never called.

    add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'woocommerce_show_product_loop_last_one' ), 30 );

    My action (never invoked) is:

    function woocommerce_show_product_loop_last_one() {
    			    global $product;
    			$lastMsg     		= get_option( 'wc_lastone_title' );
    
    				if ($product->get_stock_quantity() == 1  ) { // If the inventory = 1, show the msg
    					echo '<br><span class="wc-lastone-badge">' . $lastMsg . '</span>';
    				}
    				else if ($product->get_stock_quantity() == 0  ) { // out of stock - sold out
    					echo '<br><span class="wc-soldout-badge">Sold Out!</span>';
    				}
    			}

    WC Version: 2.1.7
    WC Database Version: 2.1.7
    WP Version: 3.8.1

    My theme is Virtue Version: 2.1.2 with a child theme and haven’t overridden any Woo pages, just some filters in my functions.

    I removed my filters with no affect. I think the theme may have been updated recently, so maybe the theme isn’t passing on the call?

    Any ideas are appreciated!

    https://wordpress.org/plugins/woocommerce/

  • The topic ‘Product inventory filter stopped working’ is closed to new replies.