Inconsistent behavior for visibility of the Add to Cart button/link

In WooCommerce, the "Add to Cart" button is visible on the single product page when the product is purchasable and it is in stock. See woocommerce\templates\single-product\add-to-cart\simple.php for reference. In BeTheme, the Add to Cart link is visible when the product is in stock and regardless of the product's purchasable property. See themes\betheme\woocommerce\content-product.php for reference. When the Add to Cart link is clicked for the product that is in stock but with empty price, an error message is displayed that the product cannot be added to the cart. 

Please make the behavior of the Add to Cart link and the Add to Cart button consistent.

Comments

  • Hi,
    We tested it, and we do not have such a problem.
    Please disable all of the plugins, clear the cache and check again.
    Also, be sure that your theme is Parent Theme and it's up to date.


    Thanks.
  • edited September 2018
    Thanks for the quick replay. I just updated BeTheme to the latest version, disabled plugins and can still reproduce the issue.
    I am pretty sure it is caused by missing check for product->is_purchasable() in \betheme\woocommerce\content-product.php line 31.

    Could you see if you can reproduce the issue using the hook below? The hook forces product->is_purchasable() to return false regardless of the product price.

    function custom_woocommerce_is_purchasable($product){
        return false;
    }
    add_filter('woocommerce_is_purchasable', 'custom_woocommerce_is_purchasable');

    With the hook applied the Add to Cart icon is still showing up for products. (see http://prntscr.com/kqf3ob), but there is no Add to Cart button on the product detail page. See http://prntscr.com/kqf3v3

  • Sorry, but we did not test this script/plugin with the theme. Our policy
    states that we do not support third party plugins or custom code.

    If your files were customized or they won't work properly, please reinstall WooCommerce plugin.
    Thanks.
  • edited September 2018
    Is it feasible for you to share the URL and credentials of the BeTheme web site where I can help to reproduce the issue?

    Below are more details on how to reproduce it. 

    1) Create a new simple product. Do not enter any price, but change the stock status to out of stock.
    2) Publish the product and view it.
    3) Make sure the Add to Cart button is not visible on the product detail page. It is expected because the product is not purchasable. http://prntscr.com/kqhhwf
    4) Now create one more simple product. Give it a name and also add the product from item#1 to Up sells. Publish it and then view it. 
    5) Notice that in the "You may also like" section the product from item #1 is showing up. There is also the Add to Cart icon. http://prntscr.com/kqhmap This is not expected. When the icon is clicked, an error message is displayed that the product cannot be added to the cart. http://prntscr.com/kqhmyx

    A bit of technical details, the content for the product detail page comes from woocommerce\templates\single-product\add-to-cart\simple.php. The content for the "You may also like" section comes from \betheme\woocommerce\content-product.php. 
  • We test the woocommerce plugin every time there is an update. It works fine and does not generate any problems.
    Please do not use any other plugins that we recommend, in almost all cases any issues with the woocommerce plugin are generated by those plugins.
    We do not also support theme or plugin file changes. This is how the plugin works and we cannot change it.


Sign In or Register to comment.