How to find/delete/invalidate DiscountCode by code?
See original GitHub issueI want to delete one DiscountCode from the list of assigned to some PriceRule. How should I do that having only DiscountCode without ID? I don’t want to retrieve a list of all discounts (I have thousands of them), just delete or invalidate one.
Currently, the only option I see - is to find somehow ID of required DiscountCode and destroy()
it.
But the question is still how to find it? In tests, I see only hardcoded ID.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
This Website Accidentally Left Promo Codes in Their Source ...
Right-click just about anywhere on the website and select “View source.” Hit CTRL+F (or CMD+F) to search the code and type “promocode.” We...
Read more >Discount codes FAQ - Shopify Help Center
Find answers to common questions about discount codes. ... What happens if a customer enters an invalid discount code or combination? How do...
Read more >Delete a coupon – curl - Stripe API reference
You can delete coupons via the coupon management page of the Stripe dashboard. ... An object with the deleted coupon's ID and a...
Read more >Fix issues with promotions - Google Store Help
Fix issues with promo codes · At the bottom of the checkout screen, find "Add a promo code." · Enter your code. ·...
Read more >Managing discounts - Squarespace Help Center
Confirm that the discount has a unique code. Review active, scheduled, and expired discounts and change any duplicate codes. If the discount is ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I actually don’t think this is going to work without patching
urllib
, which should probably be done inpyactiveresource
.urllib
will follow 303 redirects without using a custom handler, which is not the ideal behaviour here.In the meantime, you can use the
requests
library to do something like this:Thanks @jamiemtdwyer I just added
shopify.DiscountCode._build_collection(code, prefix_options='')
to build the respone dictionary back into the library object. Also, this issue is quite old now. Is there any better approach to achieve this?