Home › Forums › Themes Support › Claue › add "add to cart" button to homepage thumbnail
- This topic has 7 replies, 3 voices, and was last updated 7 years, 7 months ago by Harry.
-
AuthorPosts
-
-
May 19, 2017 at 9:33 pm #4335
How to add “add to cart” and “quantity” plus minus to homepage (somewhere at the bottom of the price)
Attachments:
You must be logged in to view attached files. -
May 19, 2017 at 9:35 pm #4337
is it copy the exact code as below and paste there?
<?php if ( ! defined( ‘ABSPATH’ ) ) {
exit;
}global $product;
if ( ! $product->is_purchasable() ) {
return;
}$ajax_btn = get_option( ‘woocommerce_enable_ajax_add_to_cart_single’ );
$redirect = get_option( ‘woocommerce_cart_redirect_after_add’ );echo wc_get_stock_html( $product );
if ( $product->is_in_stock() ) : ?>
<?php do_action( ‘woocommerce_before_add_to_cart_form’ ); ?>
<form class=”cart” method=”post” enctype=’multipart/form-data’>
<?php
/**
* @since 2.1.0.
*/
do_action( ‘woocommerce_before_add_to_cart_button’ );/**
* @since 3.0.0.
*/
do_action( ‘woocommerce_before_add_to_cart_quantity’ );woocommerce_quantity_input( array(
‘min_value’ => apply_filters( ‘woocommerce_quantity_input_min’, $product->get_min_purchase_quantity(), $product ),
‘max_value’ => apply_filters( ‘woocommerce_quantity_input_max’, $product->get_max_purchase_quantity(), $product ),
‘input_value’ => isset( $_POST[‘quantity’] ) ? wc_stock_amount( $_POST[‘quantity’] ) : $product->get_min_purchase_quantity(),
) );/**
* @since 3.0.0.
*/
do_action( ‘woocommerce_after_add_to_cart_quantity’ );
?><?php if ( $ajax_btn == ‘no’ || $redirect == ‘yes’ ) { ?>
<button type=”submit” name=”add-to-cart” value=”<?php echo esc_attr( $product->get_id() ); ?>” class=”single_add_to_cart_button button alt”><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
<?php } else { ?>
<input type=”hidden” name=”add-to-cart” value=”<?php echo esc_attr( $product->get_id() ); ?>” /><button type=”submit” name=”add-to-cart” class=”single_add_to_cart_button button alt”><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
<?php } ?><?php
/**
* @since 2.1.0.
*/
do_action( ‘woocommerce_after_add_to_cart_button’ );
?>
</form><?php do_action( ‘woocommerce_after_add_to_cart_form’ ); ?>
<?php endif; ?>
-
May 19, 2017 at 9:49 pm #4338
Hi,
You can put that code into functions.php of claue child theme. Where did you get this code?
-
May 19, 2017 at 9:51 pm #4339
from ../single-product/add-to-cart/simple.php
put what code into functions.php? how to do?
-
May 19, 2017 at 9:57 pm #4340
No, You can do like this, let me research and give you the solution
-
May 19, 2017 at 10:11 pm #4341
Hi,
You can use this code https://pastebin.com/C0nhXLfr add it into functions.php file of child theme
Foster
-
May 19, 2017 at 10:22 pm #4342
thanks… prefect! you are the best hehe
-
May 21, 2017 at 7:47 pm #4381
Hope you love our theme and take a time to help us give our theme good review at https://themeforest.net/downloads. We really appreciate.
Thank you so much!
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio
-
-
AuthorPosts
You must be logged in to reply to this topic.