Remove Add To Cart button on Free products AND add Custom Shortcode
Question
OK, I want to do two things.
1.) on free products remove the add to cart button. I think the following code from this post will work to do that?
function remove_add_to_cart_option( $purchasable, $product ){
if( $product->get_price() == 0 )
$purchasable = false;
return $purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'remove_add_to_cart_option', 10, 2 );
Correct?
2.) I want to add a shortcode if a product is free and downloadable. The shortcode is from another plugin (PDF viewer). And I need to insert the URL of the downloadable file from WooCommerce into the shortcode.
[tnc-pdf-viewer-image file="**URL OF WOOCOMMERCE DOWNLOAD FILE**" target="_parent" download="false" print="false" fullscreen="true" share="false" zoom="true" open="false" pagenav="true" logo="true" find="true" current_view="true" rotate="true" handtool="true" doc_prop="false" toggle_menu="true" toggle_left="true" scroll="true" spread="true" default_scroll="1" default_spread="0" language="en-US" class="" page="" default_zoom="auto" pagemode="none"]READ ONLINE FOR FREE[/tnc-pdf-viewer-image]
I need this shortcode to appear where the Add TO Cart Button was previously.
Thoughts?
0
2 months
0 Answers
4 views
0
Leave an answer
You must login or register to add a new answer .