WordPress WooCommerce:给另一个按钮 'add to cart' 功能
WordPress WooCommerce: give another button 'add to cart' function
我想将 'add to cart' 的功能赋予另一个 html 元素。这可能吗?我已将一些 html 代码添加到 single-product.php 中,并希望这些元素之一在您单击它们时充当 'add to cart' :)
我希望我已经能够解释我自己 :P
以下将用作产品循环中的添加到购物车按钮,其中 $product
是 post 对象 -
<?php if( $product->is_purchasable() ):?>
<form class="cart" method="post" enctype='multipart/form-data'>
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />
<button type="submit">Add to Cart</button>
<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
</form>
<?php endif; ?>
我想将 'add to cart' 的功能赋予另一个 html 元素。这可能吗?我已将一些 html 代码添加到 single-product.php 中,并希望这些元素之一在您单击它们时充当 'add to cart' :)
我希望我已经能够解释我自己 :P
以下将用作产品循环中的添加到购物车按钮,其中 $product
是 post 对象 -
<?php if( $product->is_purchasable() ):?>
<form class="cart" method="post" enctype='multipart/form-data'>
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />
<button type="submit">Add to Cart</button>
<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
</form>
<?php endif; ?>