-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Coupon Code? #1641
Comments
There's no in-build way currently. One one occasion I had a custom endpoint built: class CouponCodesController < Spree::StoreController
before_action :find_order
def destroy
@handler = Spree::PromotionHandler::Coupon.new(@order).destroy!
end
private
def find_order
@order = current_order
render_404 unless @order
end
end # added to Spree::PromotionHandler::Coupon
def destroy!(perform_update: true)
order.order_promotions.select(&:has_code?).map(&:destroy)
order.adjustments.promotion.select(&:has_code?).map(&:destroy)
order.line_item_adjustments.promotion.select(&:has_code?).map(&:destroy)
order.shipment_adjustments.promotion.select(&:has_code?).map(&:destroy)
order.update! if perform_update
set_success_code :coupon_code_removed
self
end |
Thanks @mtomov . I ended up building a customized endpoint for remove coupon also, similar idea followed :) |
undefined method `remove' for #Spree::PromotionHandler::Coupon:0x00007fbf4368ec28 |
Reopened since I think Solidus still need this endpoint |
Working on it! |
@aitbw I think also @loicginoux is working on it, please coordinate 🤝 |
checked on Slack, he is doing it. |
We just talked about needing this at Engine. Thanks! |
Currently, we can apply coupon code via endpoint
/api/orders/:id/apply_coupon_code
.However, how to remove a coupon code?
The text was updated successfully, but these errors were encountered: