• Resolved eqr

    (@eqr2020)


    Products on the wishlist that are out of stock currently look like they are free even though they aren’t.

    How do I fix this?

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi there

    I just did a quick test, and this doesn’t seem the case (check my screenshot for reference)
    Indeed, the “Free!” label should appear only when regular price of the product is 0 or empty

    If this is not the case, maybe your theme bundles outdated version of wishlist templates, and you may want to update or remove them

    Thread Starter eqr

    (@eqr2020)

    Hello and thanks for getting back to me!

    I am using the Flatsome theme. How do I go about to update wishlist templates?

    Best regards EQR

    Plugin Author YITHEMES

    (@yithemes)

    Hi there

    This is really strange, since Flatsome do not override wishlist-view.php template
    Indeed, I get the same result when I activate Flatsome theme on my local installation (check my screenshot)

    Could you please double check your product configuration? Do you have a price properly set? Could you please share with me url to the page of the out of stock product that I could use to replicate the issue on your site?

    Thread Starter eqr

    (@eqr2020)

    The product prices should be OK. They’re imported from our POS system (we have a physical store) and all that integration does is put the price on the products.. so if it works on products in stock, it should work for products out of stock? At least when I go check whether prices are set up right, they look fine.

    We hide out-of-stock products on our website (for the same reason, as we have a lot of registered products in our POS system, including outdated products, that shouldn’t show up on the website). Hiding the products is just through the standard WooCommerce feature, so nothing extraordinary there.. but it does mean that the product page just says “product no longer available”.

    Here’s an example product: https://equirider.dk/shop/hund/traeningsudstyr/clicker/
    Product costs 19 dkk.

    • This reply was modified 3 years, 10 months ago by eqr.
    Plugin Author YITHEMES

    (@yithemes)

    Hi again

    could you please explain me better how you hide those products? I’m exploring combination of options, since just the stock status doesn’t seem to be the cause of the issue
    Do you use Shop Visibility option in product edit? If you set a product as “Hidden”, it shouldn’t appear in wishslit too

    Thread Starter eqr

    (@eqr2020)

    Hello

    Of course!

    WooCommerce – Settings – Products – Stock, and then I’ve just ticked the option to Hide Out of Stock products.

    View post on imgur.com

    Plugin Author YITHEMES

    (@yithemes)

    HI there

    I tested this configuration on my local installation and, while I still see Out of Stock products inside wishlist (this may be actually wrong), the price is always correct (here a screen of my test)

    For this reason I beleieve that the problem could be related to some external interference
    Do you happen to have a staging site where you can test with just Flatsome, WooCommerce and Wishlist activated, and let me know fi the problem persists?
    Additionally, can you export one of the products that has problems, and send it to me, so I can import it and check product configuration (You can export products using WC’s export tool)?

    Thread Starter eqr

    (@eqr2020)

    I sadly don’t have a staging solution currently.

    But I just tried to test it with two other themes (Customify and default Storefront) and in both cases, the product is still listed as Free.

    Deactivating almost all my plugins also didn’t do anything.

    Removing all custom functions in my theme folder, once again, nothing different on Wishlist. πŸ™

    By exporting products, do you just mean Tools -> Export -> Products? Wouldn’t that export all of them? We have quite a number already. How do I go about sending one product to you?

    Plugin Author YITHEMES

    (@yithemes)

    Thank you for your testing, really helps narrow down the chances
    Regarding export, I mean the one bundled with WooCommerce (WP Dashboard -> Products -> All products -> Export)

    Using this tool you can export just specific categories of products, so I suggest you to assing the product that has problems a specific category, and export just that category

    Thread Starter eqr

    (@eqr2020)

    Alright, thank you very much!!

    I exported the .csv file. How do I send it to you? Via e-mail?

    Thread Starter eqr

    (@eqr2020)

    So here’s something interesting to add!

    I just added another product that’s out of stock to my wishlist; and this product displays its price.

    The difference between this product, and the other two on my list right now, is that this product doesn’t have variants.

    Thread Starter eqr

    (@eqr2020)

    It seems it’s also reflected in my product list (in which case, it must not be the plugin’s fault, but maybe WooCommerce’s..?)

    View post on imgur.com

    Products that only have one variant display with a price here, even if out of stock.
    Products with multiple variants display without a price.

    Oddly, products in stock display with price regardless if they’re variants or not, even if there’s different price ranges.

    The moment I add stock to any of the products that are listed without a price, the price displays (both here and in Wishlist). When I remove stock again, price disappears.

    Very odd… πŸ™

    Is this the same for you on your end/your local installations?

    Plugin Author YITHEMES

    (@yithemes)

    Hi there

    After much more testing, it seems that when all of variations are out of stock, it is expected for the variable product to have an empty price
    Anyway, I have little idea on why this isn’t happening for all of your out of stock variable products; my best guess on this is that WC is using outdated data from transiets stored in your DB
    If this is the case, using the specific tool to delete transients (WP Dashboard -> WooCommerce -> Status -> Tools -> Delete Transients) could help

    Anyway, now we’re left with the original question: how to work this problem around?
    I think you can obtain this result by adding the following snippet of code at the end of functions.php file of your theme or child

    function yith_wcwl_out_of_stock_price( $price_html, $base_price, $product ) {
    	/**
    	 * @var $product WC_Product
    	 */
    	if( $product->is_type( 'variable' ) && ! $product->is_in_stock() ) {
    		$children = $product->get_children();
    		$prices   = [];
    
    		if ( ! empty( $children ) ) {
    			foreach ( $children as $child ) {
    				/**
    				 * @var $child WC_Product_Variation
    				 */
    				$child = wc_get_product( $child );
    
    				if ( ! $child ) {
    					continue;
    				}
    
    				$prices[] = $child->get_price();
    			}
    
    			sort( $prices );
    
    			$min_price = current( $prices );
    			$max_price = end( $prices );
    
    			return sprintf( '%s - %s', wc_price( $min_price ), wc_price( $max_price ) );
    		}
    	}
    
    	return $price_html;
    }
    add_filter( 'yith_wcwl_item_formatted_price', 'yith_wcwl_out_of_stock_price', 10, 3 );
    

    I’ll study further to understand if this is something that we should add to our plugin, but for the moment I’ll stick with WooCommerce’s behaviour

    Thread Starter eqr

    (@eqr2020)

    Thank you so much! Works like a charm now. πŸ™‚

    And thanks a bunch for all your time with this issue! I am very grateful for the support I have received.

    Best regards!

    Thread Starter eqr

    (@eqr2020)

    Is there a way to remove the link to the website please? This topic is showing up in search results for the website and I’d like that to not be the case.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Out of stock products have no price (“Free!”)’ is closed to new replies.