Skip to content

Conversation

@louwie17
Copy link
Contributor

@louwie17 louwie17 commented Dec 3, 2021

Fixes #68

Description

Added a Coupon generator with a min and max option for the int_random function.

I also added a coupon option to the order generator CLI command, which if set, it will auto generate a coupon for each order.

Testing instructions

  • Run wp wc generate coupons 10 --min=10 --max=40
  • Go to Marketing > Coupons and see if there are 10 new coupons (no duplicates)
  • Run wp wc generate orders 10 --status=completed --coupons=true
  • Run wp action-scheduler run
  • Go to Analytics > Coupons and see if there are 10 coupons listed with an order each

Changelog entry

Add: coupon generator and a new option for orders to allow for coupon generation.

@rrennick rrennick added the enhancement Improvements that slightly enhance existing functionality and are fast to implement. label Dec 6, 2021
@rrennick
Copy link
Contributor

rrennick commented Dec 6, 2021

@louwie17 Thanks for the PR. Could you add a change log entry to your PR description? There is also a merge conflict that needs to be addressed.

@louwie17 louwie17 force-pushed the add-coupons-generator branch from 3ca95ab to 89052c1 Compare December 6, 2021 17:34
@louwie17
Copy link
Contributor Author

louwie17 commented Dec 6, 2021

@louwie17 Thanks for the PR. Could you add a change log entry to your PR description? There is also a merge conflict that needs to be addressed.

Hi @rrennick, I added the change log entry and rebased the branch.

Copy link
Contributor

@rrennick rrennick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@louwie17 This tested great for me. I only had the two minor issues that need to be looked at. Once those are fixed I'll be able to merge this.


$order->set_date_created( $date );

$include_coupon = ! empty( $assoc_args['status'] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be $assoc_args['coupons']?

* @return \WC_Customer Customer object with data populated.
*/
public static function generate( $save = true, $min = 5, $max = 100 ) {
self::init_faker();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t doesn't look like the faker is used in this function.

@louwie17 louwie17 requested a review from rrennick December 10, 2021 00:16
@louwie17
Copy link
Contributor Author

@louwie17 This tested great for me. I only had the two minor issues that need to be looked at. Once those are fixed I'll be able to merge this.

Thanks for the review @rrennick, great catch on both of those, I have pushed up those changes in this commit: 1d497d4

Copy link
Contributor

@rrennick rrennick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@louwie17 Thanks for the help.

@rrennick rrennick merged commit bb1165d into trunk Dec 13, 2021
@rrennick rrennick deleted the add-coupons-generator branch December 13, 2021 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvements that slightly enhance existing functionality and are fast to implement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Coupon Generator

3 participants