Cart Transform Extension
The cart transform function automatically adds MUP levy charges to carts when products are priced below the minimum unit price.
What It Does
When a customer adds an alcohol product to their cart:
1. Checks if the product has alcohol units (total_units metafield)
2. Calculates price per unit
3. Compares to minimum unit price (£0.65)
4. If price per unit < minimum, adds levy charge
5. Adds levy as a child line item
How It Works
Automatic Execution
The cart transform runs automatically when: - Customer adds product to cart - Customer changes quantity - Cart is updated - Region is changed to Scotland
Levy Calculation
Formula:
Price per unit = Product price / Alcohol units
MUP floor = Alcohol units × £0.65
Levy needed = MUP floor - Price per unit (if positive)
Example: - Product: £1.00, 2.5 units - Price per unit: £1.00 / 2.5 = £0.40 - MUP floor: 2.5 × £0.65 = £1.625 - Levy needed: £1.625 - £1.00 = £0.625 (rounded up to £0.63)
What Gets Added
When levy is needed, the cart transform adds:
- Original product at its original price (with original_price attribute)
- MUP Levy line item with the levy amount
Both items appear in the cart as separate line items.
Requirements
For the cart transform to work:
- Customer region must be set to "Scotland"
- Product must have
custom.total_unitsmetafield - MUP enforcement must be enabled in settings
- Levy product must be configured and published
Customer Experience
Before levy: - Cart shows: Product × 1 @ £1.00
After levy (if needed): - Cart shows: - Product × 1 @ £1.00 - MUP Levy × 1 @ £0.63
The levy appears as a separate line item, clearly labeled.
Levy Attributes
The levy line item includes attributes:
- mup: true - Identifies it as a levy
- parent_line_id - Links to the original product
- mup_levy_per_item - Levy amount per item
- mup_total_units - Alcohol units for validation
- mup_minimum_unit_price - MUP floor for validation
Troubleshooting
Levy not being added?
- Check customer has selected Scotland as region
- Verify product has total_units metafield
- Ensure MUP enforcement is enabled
- Check levy product is published
Wrong levy amount?
- Verify total_units metafield is correct
- Check minimum unit price setting
- Review product price
Levy added twice? - This should not happen - contact support if it does - Check cart for duplicate levy items
Levy not removed when region changes? - Cart transform should remove levies when region changes - Refresh cart page if needed
For more help, see Troubleshooting.