-
AuthorPosts
-
September 23, 2017 at 12:44 pm #855783
Hello good day!
Since the end of the web I have not been able to solve this. I would like to “please” help me solve itIt turns out that items with zero price or out of stock still showing the buy button. although they are not available and have a zero price. as you can see in this screenshot:
https://s26.postimg.org/fl8i1g4yx/noprice.jpgEven the product page shows the buy button. even if they are out of stock and have a zero price. as you can see in this screenshot:
https://s26.postimg.org/4zt836o15/noprice2.jpgand the result when clicking is an error in Amazon when redirecting. as you can see in this screenshot.
https://s26.postimg.org/ujvi9m9ex/noprice3.jpgIs there any way for that button to disappear from products with zero price? or any other idea?
I already tried with all this and it did not work, now I return it and I wish that we can find a solution.
https://gist.github.com/mikejolley/1751128
https://wisdmlabs.com/blog/the-right-way-to-hide-add-to-cart-button-in-woocommerce/
https://kriesi.at/support/topic/add-to-cart-button-showing-when-items-not-in-stock-after-woocommerce-update/
https://kriesi.at/support/topic/hide-out-of-stock-products-in-woocommerce/Thanks
- This topic was modified 7 years, 1 month ago by Astrobiologic.
September 25, 2017 at 5:31 am #856303Hey Ganubis,
Thank you for using Enfold.
Did you install a third party plugin to redirect the add to cart item to amazon?
Best regards,
IsmaelOctober 8, 2017 at 10:02 pm #861679Hi, I’m having a similar issue to Ganubis. The add to cart button is shown even products are out of stock. When I change the theme to TwentySeventeen, the cart button is greyed out for products that are unavailable – which is correct – but when Enfold is activated is doesn’t get greyed out/hidden.
Ideally, I’d like to remove the add to cart and quantity selector when products are out of stock or zero priced.
Enfold team – please can you help modify this function/filter to work with Enfold:
function remove_add_to_cart_on_0 ( $purchasable, $product ){ if( $product->get_price() == 0 ) $purchasable = false; return $purchasable; } add_filter( 'woocommerce_is_purchasable', 'remove_add_to_cart_on_0', 10, 2 );
Many thanks
DuncanOctober 9, 2017 at 11:26 am #861838Hi Duncan,
This code should work, have you tried it?
Or try like thisfunction remove_add_to_cart_on_0 ( $purchasable, $product ) { if( $product->get_price() == 0 || '' !== $product->get_price() ) { return false; } return $purchasable; } add_filter( 'woocommerce_is_purchasable', 'remove_add_to_cart_on_0', 10, 2 );
Best regards,
VictoriaOctober 9, 2017 at 11:47 am #861852Hi Victoria, thanks for the quick reply.
Yes, the code does work in that clicking the ‘Add to Cart’ button opens a pop-up window saying “this product is unavailable, please choose a different combination” but I’m trying to get it to remove the Add to Cart button completely when the product has a price of zero.
Any tips on how I can add a filter in the functions to remove the Cart button and quantity selector, please?
Many thanks
DuncanOctober 10, 2017 at 7:38 am #862327Hi,
Please replace the filter with the following code.
add_action( 'init', 'after_setup_theme_product_button', 100 ); function after_setup_theme_product_button() { remove_action( 'woocommerce_after_shop_loop_item', 'avia_add_cart_button', 16); add_action( 'woocommerce_after_shop_loop_item', 'avia_add_cart_button_mod', 16); } function avia_add_cart_button_mod() { global $product, $avia_config; if( $product->get_price() == 0 ) return; var_dump($product->get_price()); if ($product->get_type() == 'bundle' ){ $product = new WC_Product_Bundle($product->get_id()); } $extraClass = ""; ob_start(); woocommerce_template_loop_add_to_cart(); $output = ob_get_clean(); if(!empty($output)) { $pos = strpos($output, ">"); if ($pos !== false) { $output = substr_replace($output,"><span ".av_icon_string('cart')."></span> ", $pos , strlen(1)); } } if($product->get_type() == 'variable' && empty($output)) { $output = '<a class="add_to_cart_button button product_type_variable" href="'.get_permalink($product->get_id()).'"><span '.av_icon_string("details").'></span> '.__("Select options","avia_framework").'</a>'; } if(in_array($product->get_type(), array('subscription', 'simple', 'bundle'))) { $output .= '<a class="button show_details_button" href="'.get_permalink($product->get_id()).'"><span '.av_icon_string("details").'></span> '.__("Show Details","avia_framework").'</a>'; } else { $extraClass = "single_button"; } if(empty($extraClass)) $output .= " <span class='button-mini-delimiter'></span>"; if($output && !post_password_required() && '' == avia_get_option('product_layout','')) { echo "<div class='avia_cart_buttons $extraClass'>$output</div>"; } }
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.