• Resolved startechmarketing

    (@startechmarketing)


    Hi, I have woocommerce wishlist and request a quote plugin installed, in our beta staging site we are testing the code below, but when I add this code the add to wishlist button also disappears, can you help me with the code ?

    function wpcustom_is_purchasable( $purchasable, $product ){
        if( $product->get_price() == 0 )
            $purchasable = false;
        return $purchasable;
    }
    add_filter( 'woocommerce_is_purchasable', 'wpcustom_is_purchasable', 10, 2 );
    
    //Hide Price when Price is Zero
    add_filter( 'woocommerce_get_price_html','maybe_hide_price',10,2);
    function maybe_hide_price($price_html, $product){
         if($product->get_price()>0){
              return $price_html;
         }
         return '';
     } 
    // End of above code

    The inspect element for the add to wishlist when the code above is not acti activated is:

    <div id="wl-wrapper" class="woocommerce wl-button-wrap wl-row wl-clear ">
    <a rel="nofollow" href="" data-productid="10971" data-listid="" class="wl-add-to wl-add-but button ">
    Add to wishlist </a>
    </div>

    thanks

Viewing 1 replies (of 1 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @startechmarketing

    From your provided information, the ‘add to wishlist’ button seems to disappear when you add your custom code to your WooCommerce site. This could happen due to a conflict between your custom code and the wishlist plugin’s code.

    The function ‘wpcustom_is_purchasable’ you’ve written correctly sets the product as not purchasable when the price is zero, and the ‘maybe_hide_price’ function correctly hides the price when it’s zero. However, it seems like the wishlist plugin might be checking if the product is purchasable before displaying the ‘add to wishlist’ button.

    Unfortunately, custom coding is not something we can assist with directly. However, I’ll keep this thread open for a bit to see if anyone from the community can lend a hand.

    If you have any further questions on development or custom coding, don’t hesitate to reach out to some of the great resources we have available for support. Our WooCommerce community is brimming with skilled open-source developers who are active on the following channels:

    I hope this helps! If you have any other questions, please don’t hesitate to ask. Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘hide cart when price is 0 code wishlist’ is closed to new replies.