Woocommerce Wordpress 条件标签
Woocomerce Wordpress Conditional Tags
是否可以在 WordPress 中使用 Woocomerce 中的一种条件标签?
<script type="text/template" id="tmpl-variation-template">
<div class="woocommerce-variation-description">{{{ data.variation.variation_description }}}</div>
<div class="woocommerce-variation-price">{{{ data.variation.price_html }}}</div>
<div class="woocommerce-variation-availability">{{{ data.variation.availability_html }}}</div>
<div class="woocommerce-variation-custom_field" id="preview-spotify">
<iframe src="https://open.spotify.com/embed/track/{{{ data.variation.cfwc_spotify_url}}}" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
</div>
</script>
<script type="text/template" id="tmpl-unavailable-variation-template">
<p><?php esc_html_e( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ); ?></p>
</script>
这是我的模板,我想打印 woocommerce-variation-custom_field div,前提是有 data.variation.cfwc_spotify_url 集。
这可能吗?
您可以使用评估标签<# #>
<# if ( data.value ) { #>
your code here {{{ data.value }}}
<# } #>
是否可以在 WordPress 中使用 Woocomerce 中的一种条件标签?
<script type="text/template" id="tmpl-variation-template">
<div class="woocommerce-variation-description">{{{ data.variation.variation_description }}}</div>
<div class="woocommerce-variation-price">{{{ data.variation.price_html }}}</div>
<div class="woocommerce-variation-availability">{{{ data.variation.availability_html }}}</div>
<div class="woocommerce-variation-custom_field" id="preview-spotify">
<iframe src="https://open.spotify.com/embed/track/{{{ data.variation.cfwc_spotify_url}}}" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
</div>
</script>
<script type="text/template" id="tmpl-unavailable-variation-template">
<p><?php esc_html_e( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ); ?></p>
</script>
这是我的模板,我想打印 woocommerce-variation-custom_field div,前提是有 data.variation.cfwc_spotify_url 集。
这可能吗?
您可以使用评估标签<# #>
<# if ( data.value ) { #>
your code here {{{ data.value }}}
<# } #>