WooCommerce在特定类别的单产品页面上的自定义按钮
您好,下面的代码正常工作,但这并不是“添加到购物车”按钮的内联。我希望此自定义按钮内联添加到购物车中。
add_action( 'woocommerce_single_product_summary', 'custom_button_by_categories', 36 ,0 );
function custom_button_by_categories(){
global $product;
// Define your categories in this array (can be Ids, slugs or names)
$product_cats = array('mobile-touch', 'music', 'furnitures');
if( has_term( $product_cats, 'product_cat', $product->get_id() ) ){
$demo_url = get_post_meta( $product->get_id(), 'demo_url', true );
echo '<a class="fancybox iframe" data-width="1280" data-height="820" a href="https://lab.dmarket.pk/" target="_blank" rel="noopener"><button style="background: #007bc4; color: #ffffff; border-radius: 5px;margin-top: -120px !important;margin-left: 220px !important; padding-left: 19px; padding-right: 19px;"> Fix My Device</button></a>';
}
}
Hello This Below Code is working fine but this is not inline to "Add to Cart" button. I Want This Custom Button To Inline Add To Cart.
add_action( 'woocommerce_single_product_summary', 'custom_button_by_categories', 36 ,0 );
function custom_button_by_categories(){
global $product;
// Define your categories in this array (can be Ids, slugs or names)
$product_cats = array('mobile-touch', 'music', 'furnitures');
if( has_term( $product_cats, 'product_cat', $product->get_id() ) ){
$demo_url = get_post_meta( $product->get_id(), 'demo_url', true );
echo '<a class="fancybox iframe" data-width="1280" data-height="820" a href="https://lab.dmarket.pk/" target="_blank" rel="noopener"><button style="background: #007bc4; color: #ffffff; border-radius: 5px;margin-top: -120px !important;margin-left: 220px !important; padding-left: 19px; padding-right: 19px;"> Fix My Device</button></a>';
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
woocommerce_single_product_summary
用woocommerce_after_add_to_cart_cart_button
应该做工作Replacing
woocommerce_single_product_summary
withwoocommerce_after_add_to_cart_button
should do the job