0
我在函數function.php中的這個簡單函數上已經足夠了,讓我添加一個複選框給優惠券。但是,一旦我保存/更新優惠券,我的複選框值(選中/未選中)不會被提交(因此複選框始終未選中)。換句話說,當我更新/保存時,我無法在postmetas的meta_value列中將值更新爲yes。複選框在那裏,我只是不能使用它......非常令人沮喪!在我做錯了任何sugestions,請:)Woocommerce優惠券添加自定義複選框
function add_coupon_revenue_dropdown_checkbox() {
$post_id = $_GET['post'];
woocommerce_wp_checkbox(array('id' => 'include_stats', 'label' => __('Coupon check list', 'woocommerce'), 'description' => sprintf(__('Includes the coupon in coupon check drop-down list', 'woocommerce'))));
$include_stats = isset($_POST['include_stats']) ? 'yes' : 'no';
update_post_meta($post_id, 'include_stats', $include_stats);
do_action('woocommerce_coupon_options_save', $post_id);
}add_action('woocommerce_coupon_options', 'add_coupon_revenue_dropdown_checkbox', 10, 0);
我想影響的部分是:
的wp-content /插件/ woocommerce /包括/管理/元盒/ class-wc-meta-box-coupon-data.php
哈哈,在我看到你的之前張貼了我的回答!是的,我現在瞭解這個過程。謝謝您的回答 :) – axelra82