Skip to content

Instantly share code, notes, and snippets.

@praveencs87
Created November 24, 2020 13:01
Show Gist options
  • Save praveencs87/b703bd91e383554905e28b6fad334197 to your computer and use it in GitHub Desktop.
Save praveencs87/b703bd91e383554905e28b6fad334197 to your computer and use it in GitHub Desktop.
<?php
// Code Description given in https://webinwordpress.com/uncategorized/how-to-create-and-apply-coupon-code-programmatically-in-woocoomerce/
//use code below to apply the coupon code $coupon_code
if (! WC()->cart->add_discount( sanitize_text_field( $coupon_code )))
WC()->show_messages();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment