Repository navigation
fix(checkout, settings): storefront hardening, delivery currency, settings layout - #34
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes checkout and storefront gaps that could charge customers the wrong amount or expose internal data. Fixes delivery cost currency. Tidies the settings and product list screens in the manager. Adds standalone tests for all
of it.
Checkout and storefront
processOrder()reprices the lines it stored atinitCheckout()using current prices, publication status, stock and currency. If anything changed, it saves thecurrent lines and returns
error_code: cart_changedwith the newproductsandcost. The customer then confirms the order again.sCart::shortages()is used by checkout and by quick orders (single product and cart). Lines above stock fail without_of_stock.StorefrontGuard::purchasable()is checked inaddProduct(),getMiniCart()and quick orders.setOrderData()and again inprocessOrder(). The cost stored in the session is no longer trusted.BaseDeliveryMethod::getCostCurrency(), returns the currency of the method's settings row, orthe main shop currency if that row has none.
CourierDeliverynow matches city names case-insensitively in any script, including Cyrillic.processOrder()restores the checkout data and session, so a retry no longer adds the delivery cost twice.productIdorders the cart. Any value that isn't a whole number counts as an unknown product instead of causing aTypeError.removeProduct()rejects malformed ids.MeasuredQuantity::PIECE_MAX(1,000,000).process-orderandquick-orderroutes returnsOrder::toCustomerArray(), which leaves out manager notes, history andmeta.id,titleandlink, not the full product row.orders.rate_limit(default 10 orders per IP address per 10 minutes; 0 = no limit). Requests above the limit get429withrate_limited. If no cache store is available, orders are stillallowed.
product.container_exchange_on, off by default. A customer's declared exchange waives the deposit before anyone has seen the containers. While the setting is off, theroute returns
404and declared exchanges are ignored.Manager UI
settingsMeasuredQuantitiesConfiguration).sProduct::priceNetTo()). It appears only while prices without VAT are on, and can be turned off withproducts.show_field_price_net.Docs and translations
events,deliveriesandpaymentsdeveloper docs (en/ru/uk).lang/*/global.phpfiles.Tests
tests/standalone/scommerce-storefront-hardening.php: unpublished products, malformed ids, quantity caps, negative prices, stock, repricing (price, publication, currency), delivery currency and address recalculation,retry rollback, the customer order payload and the rate limit.
tests/standalone/scommerce-ukraine-beer.php: an end-to-end example selling beer in Ukraine. Prices include 20% VAT and 5% retail excise, and the bottle deposit sits outside both.publishedflag) and the existing measured-quantity, container-deposit, payment-schedule and VAT-display tests.Breaking / behaviour changes
processOrder()can now fail withcart_changed. Storefront JS should show the returnedproductsandcostand ask the customer to confirm again.toCustomerArray()instead of the full order model.calculateCost()is now read as being ingetCostCurrency(). Custom methods whose cost is not in the currency of their settings row should override that method.