首页 > 解决方案 > 如何在产品页面上展示?

问题描述

使用此功能,我可以选择在我的产品中使用自定义选择框。但它不会出现在产品页面元数据中。我想只为一种特殊产品展示它。我怎样才能做到这一点?

我没有任何 PHP 经验。

<?php
function prefix_add_selectbox() {
  $args = array(
    'id' => 'my_new_select', // required. The meta_key ID for the stored value
    'wrapper_class' => '', // a custom wrapper class if needed
    'desc_tip' => true, // makes your description show up with a "?" symbol and as a tooltip
    'description' => __('My awesome select box', 'your_text_domain'),
    'label' => __( 'My New Select', 'your_text_domain' ),
    'options' => array(
      'value1' => __( 'Text 1', 'your_text_domain' ),
      'value2' => __( 'Text 2', 'your_text_domain' )
    )
  );
  woocommerce_wp_select( $args );
}

add_action( 'woocommerce_product_options_tax', 'prefix_add_selectbox' );```

标签: wordpresswoocommerce

解决方案


推荐阅读