[英]WordPress do_shortcode in Woocommerce
I am using do_shortcode hook that is preventing "Add to cart" to show non-paid members. 我正在使用do_shortcode钩子,该钩子阻止“添加到购物车”显示非付费会员。
I have used the following code and the "Add to cart" doesn't seem to work. 我使用了以下代码,“添加到购物车”似乎无法正常工作。
else{
echo do_shortcode( '[ihc-hide-content ihc_mb_type="show" ihc_mb_who="1" ihc_mb_template="1" ]' . '<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>' . '[/ihc-hide-content]" );
');
It's being displayed as : 显示为:
Try this code 试试这个代码
else{
echo do_shortcode(
'[ihc-hide-content ihc_mb_type="show" ihc_mb_who="1" ihc_mb_template="1" ]' .
'<button
type="submit"
name="add-to-cart"
value="
'.<?php
esc_attr( $product->get_id() )
?>.'"
class="single_add_to_cart_button button alt">
'.<?php
esc_html( $product->single_add_to_cart_text() )
?>.'
</button>' .
'[/ihc-hide-content]" );
');
UPDATE 更新
else{
echo do_shortcode(
'[ihc-hide-content ihc_mb_type="show" ihc_mb_who="1" ihc_mb_template="1" ]' .
'<button
type="submit"
name="add-to-cart"
value="
'.
esc_attr( $product->get_id() )
.'"
class="single_add_to_cart_button button alt">
'.
esc_html( $product->single_add_to_cart_text() )
.'
</button>' .
'[/ihc-hide-content]" );
');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.