Matthew Ogborne
Matthew Ogborne

Reputation: 554

Woocommerce Create Coupons in WordPress Core

This maybe a daft question, but I couldn't find the answer (see here & here for related/unanswered questions)

What I am trying to do:

I would like to programmatically make coupons for use by Woocommerce and found the reference code here: http://docs.woothemes.com/document/create-a-coupon-programatically/

But how to actually hook this up to the WordPress core so that they are created?

Is there a specific WordPress file or files that I need to include so that I can run these actions?

Note: This is for standalone code so that I can add more when I need to.

Upvotes: 0

Views: 866

Answers (1)

Matthew Ogborne
Matthew Ogborne

Reputation: 554

For anyone else who was struggling with this too, add this to your PHP code:

define('WP_USE_THEMES', false);
global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
require('../wp-load.php');

Then you can hijack the WordPress code and create coupons, yay!

Matt

Upvotes: 1

Related Questions