samedi 25 février 2017

Woocommerce coupons adding custom checkbox

So I'm trying to figure out how I can add a function in functions.php to add a custom checkbox for coupons in woocommerce. I have a separat function for showing revenue on coupons, however, I'd like to add a checkbox on coupons, that allow me to look for that value in my coupon revenue so I can have only the coupons that have the checkobox checked show up in the drop-down list that allows me to select which coupon to view.

I've tried a bunch of things, nothing is working.

  1. because I can't figure out what the filter or action is to append to the existing coupon general tab

  2. I don't know how to get what I need in there.

    function add_coupon_list_checkbox( $post, $post_id, $include_stats ) {
    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 );
    }add_filter( 'woocommerce_coupon_data' , 'add_coupon_list_checkbox' );
    
    

This is just something I tried. I looked at the wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php. Entering the individual lines in there from my function works just fine. But I can't figure out how to hook in the the coupon from functions.php and set the custom checkbox from there, since I don't want to edit core files (for obvious reasons).




Aucun commentaire:

Enregistrer un commentaire