Support » Plugin: Easy Digital Downloads - Simple eCommerce for Selling Digital Files » Programmatically Clone Discount Code

  • Resolved umchal



    I’m trying to copy(clone) existing discount codes and create new ones (with new names) based on it programmatically and looking for a safe way and the best practice.

    By looking into the code, there is a function named edd_add_discount( $data ). It looks like it takes a nonce and some internally configured values. So I’m wondering what’s the best way to do it.

    Any help would be appreciated. Thank you!

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

    EDD discount code is a custom post type edd_discount. You can use WordPress built-in function wp_insert_post to create the discount but you must be aware about the data which needs to stored and post meta which is required to make it work properly.

    OR you can use EDD built-in function edd_store_discount by passing necessary details. One more thing you need to take care of duplication discount code by calling this function edd_get_discount_by_code.

    I hope this helps you.

    Thread Starter umchal


    It was helpful. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Programmatically Clone Discount Code’ is closed to new replies.