-
AuthorPosts
-
May 6, 2021 at 4:55 pm #1298840
Rather than having the product page open upon click of the image, I would like an add to cart button to display within the list.
I would also like the ability to zoom or open the lightbox by clicking on the thumbnail so that the user can better view the image.
Can you direct me to CSS or a plugin to achieve this?
May 11, 2021 at 8:52 am #1299594Hey Beth,
Thank you for the inquiry.
You can use this filter in the functions.php file to insert an “Add to Cart” text next to the excerpt in the catalogue item.
add_filter("get_the_excerpt", function($excerpt, $post) { if(get_post_type($post->ID) == "product") $excerpt .= "<strong class='avia-catalogue-add-to-cart'>Add to Cart</strong>"; return $excerpt; }, 10, 2);
Best regards,
IsmaelMay 11, 2021 at 1:34 pm #1299670Is there a way to make this an actual “Add to Cart” button, which adds the item to the cart, rather than just a link to the product page?
- This reply was modified 3 years, 7 months ago by cinchmedia.
May 13, 2021 at 11:01 am #1300103Hi,
That should be possible but you have to disable the product list option that applies an add to cart link to the whole item. Then replace the snippet with this one to render an actual add to cart button with a link.
add_filter("get_the_excerpt", function($excerpt, $post) { if(get_post_type($post->ID) == "product") { ob_start(); /** * hooked by: add_action( '<a href='https://refer.wordpress.com/r/84/woocommerce/' target='_blank' rel="nofollow">woocommerce</a>_single_product_summary', '<a href='https://refer.wordpress.com/r/84/woocommerce/' target='_blank' rel="nofollow">woocommerce</a>_template_single_add_to_cart', 30 ); */ do_action( '<a href='https://refer.wordpress.com/r/84/woocommerce/' target='_blank' rel="nofollow">woocommerce</a>_single_product_summary' ); $cart = ob_get_clean(); $excerpt .= $cart; } return $excerpt; }, 10, 2);
Best regards,
IsmaelMay 25, 2021 at 2:55 pm #1302232Is there a way to have both Add to Cart and See Details within the Product List? My customer has some products that the grid format does not work well. He would like simply the image, the title, price and Add to Cart or See Details.
May 27, 2021 at 12:41 pm #1302608Hi,
That should be possible. Make sure to set the element’s Advanced > Link Behavior > Item Links to the first option, then replace the filter with the following.
add_filter("get_the_excerpt", function($excerpt, $post) { if(get_post_type($post->ID) == "product") { $product = wc_get_product($post->ID); $excerpt .= "<a class='avia-catalogue-add-to-cart' href='" . $product->add_to_cart_url() ."'>Add to Cart</a>"; } return $excerpt; }, 10, 2);
The rest of the product list should link to the actual product page aside from the add to cart button.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.