spree/api expects either spree_current_user or an api token to authenticate users. Since backend no longer sends the api token we need to make sure custom auth apps have spree_current_user available in api component
Otherwise, orders that use an old cart appear way out of order. This will show completed orders first, ordered by completed_at desc, then the rest ordered by created_at desc.
We want to make Variant#cost_price only available for admins so we need to make sure difference cache keys are set as per current user role otherwise the first template cached would decide whether or not the attribute would be available (rather than the user role itself)
…sult in bad performance with many Variants
…ckout flow before displaying any shipping charges.
Spree::Product has after_save :touch in order to fire the after_touch callback. But as a result, every Save updates the product twice. There's no need to call `touch` after a save if all you want to do is fire the after_touch callback. So I fixed that. I also fixed `punch_slug`, which gets called after_destroy, so it does a single round-trip instead of about six. After a destroy has already happened, it is unnecessary to validate the product again, call callbacks again, touch the product again, and fire all cascading touches again. Closes #5049
This allows a promotion to be assigned to a category for better filtering. Add ability to search by promotion category. Manage promotion categories. Provides CRUD for promotion categories, linked from the promotions page. Closes #4992
…rrency settings are used. Fixes #4995
Extract payload to a let statement. Refactor eligible_rules to return rules. This is helpful to understand which rules a promotion matched at some point later down the promotion chain. Extract line items to adjust in to Promotion. This is part of moving the logic out of the promotion actions in to a place that knows a little more about the context of what should be applied. Add actionable? call. Move line item actionable to promotion. No adjustments for non-actionable items. The logic around this has changed a little, as adjustments are no longer created for non-eligible promotions, due to the selection on actionable. Remove products method (no longer used) This is deprecated, as this logic is all done internally by the product rule and related actions. Closes #5036
… currencies Closes #5038
…ute that is set to `Spree::ReturnAuthorizationTaxCalculator` by default. When `ReturnAuthorization#process_refund` is called, the tax calculator is called with all return items and tax is calculated and stored on each return item and then the refund is performed with the new total. Taxation is broken out like this to allow easy integration with third-party tax services. Also: - Moved some rounding further out since it was causing small but noticeable differences in refund amounts (off by 8 cents sometimes, for example). And increase precision of some return_items fields along with that. - Refactored return authorization controller specs so that the spec data is more correct - Added an additional validation to #process_refund to abort the refund if we know we don't have enough funds to reimburse the customer fully Closes #5043
and not for js requests. When a resource controller failed to create/update there was no indication of what had failed. Also adds "with_model" gem to allow easier isolated testing of `Spree::Admin::ResourceController`. Fixes #5011