• I’ve found a few gift or voucher plugins for Woocommerce able to do that. The problem is that I can NOT use my own list of custom codes (but the plugins generate their own codes randomly). I need to use our own custom codes!

    Do you know a plugin able to do that?? Thanks!

    Carlos

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Do you mean with ‘custom code’ a coupon code?

    With the code below you can generate discount codes yourself

    /**
     * Create a coupon programatically
     */
    $coupon_code = 'UNIQUECODE'; // Code
    $amount = '10'; // Amount
    $discount_type = 'fixed_cart'; // Type: fixed_cart, percent, fixed_product, percent_product
    					
    $coupon = array(
    	'post_title' => $coupon_code,
    	'post_content' => '',
    	'post_status' => 'publish',
    	'post_author' => 1,
    	'post_type'		=> 'shop_coupon'
    );
    					
    $new_coupon_id = wp_insert_post( $coupon );
    					
    // Add meta
    update_post_meta( $new_coupon_id, 'discount_type', $discount_type );
    update_post_meta( $new_coupon_id, 'coupon_amount', $amount );
    update_post_meta( $new_coupon_id, 'individual_use', 'no' );
    update_post_meta( $new_coupon_id, 'product_ids', '' );
    update_post_meta( $new_coupon_id, 'exclude_product_ids', '' );
    update_post_meta( $new_coupon_id, 'usage_limit', '' );
    update_post_meta( $new_coupon_id, 'expiry_date', '' );
    update_post_meta( $new_coupon_id, 'apply_before_tax', 'yes' );
    update_post_meta( $new_coupon_id, 'free_shipping', 'no' );

    Maybe this can help you on your way? or can you clarify your question?

    Thread Starter chelder86

    (@gmh2000)

    I think it cannot be a coupon code because it must be hide till the customer purchase the product. After the customer purchase de product, he/she should receive that unique code. We have hundred of unique codes and each customer should have a unique code.

    That’s what vouchers / gift cards plugins do… But all what I’ve tested send a random generated code, not a code from a list we provide.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Which Woocommerce plugin can send a custom code?’ is closed to new replies.