wordpress - 如何在产品页面上展示?
问题描述
使用此功能,我可以选择在我的产品中使用自定义选择框。但它不会出现在产品页面元数据中。我想只为一种特殊产品展示它。我怎样才能做到这一点?
我没有任何 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' );```
解决方案
推荐阅读
- mysql - 如何获得多列不同的值,并且任何一个不同的字段都反向具有相同的数据
- java - 字符串池是如何用java中的桶来衡量的
- php - 非静态方法如何在本地主机上静态工作
- c++ - C++ / GoogleTest - 如何为链接目录中的每个测试运行安装程序
- linux - 以水平方式打印垂直数据
- c# - 为什么这个正则表达式返回“真”?
- ios - 无法解析字符串内的字典数组
- javascript - 您如何将数据从 JS 发布到 Flask,操作数据然后将其发送回 JS?
- javascript - 当我输入 enctype="multipart/form-data" 和 input[type="file"] 时,PassportJS 出现“缺少凭据”
- javascript - 使用 JQuery 创建动态链接 - 单个帖子 ID