1. Retain order-wide
adjustments
"We screwed up. Have $20 off
your whole order."
Slide 11
Slide 11 text
2. Discounts + Credits
"Use 10off to get 10%
off this weekend!"
"We screwed up. Have $20 off
your whole order."
Slide 12
Slide 12 text
3. Discounts for specific customers
15% off for .edu customers!
5% off for members!
Slide 13
Slide 13 text
4. Shipping taxation
Shipping as a service.
Slide 14
Slide 14 text
5. Refund specific items
$3.63 GST included
10% GST
"How much tax did this item incur?"
Slide 15
Slide 15 text
6. Freeze order adjustments
Slide 16
Slide 16 text
7. Refund VAT outside of EU
Slide 17
Slide 17 text
8. Allow multiple discounts
per order
"Can I combine a free shipping promotion and
a 10% off promotion?"
"You can't!"
Slide 18
Slide 18 text
9. Robust test suite
...........................................
...........................................
...........................................
...........................................
...........................................
...........................................
...........................................
Slide 19
Slide 19 text
Events
and
Notifications
Slide 20
Slide 20 text
fire_event('spree.cart.add')
Slide 21
Slide 21 text
1.Find all Spree::Activator instances
with that event name
2. Activate them
Slide 22
Slide 22 text
#4270
Slide 23
Slide 23 text
Events
and
Notifications
Slide 24
Slide 24 text
A. Avoid excessive calculations
B. Avoid multiple adjustments per line item
C. Not overly complicate things
Ground Rules
Slide 25
Slide 25 text
A. Avoid excessive calculations
B. Avoid multiple adjustments per line item
C. Not overly complicate things
Ground Rules
Slide 26
Slide 26 text
86,082
lines
Slide 27
Slide 27 text
A. Avoid excessive calculations
B. Avoid multiple adjustments per line item
C. Not overly complicate things
Ground Rules
Slide 28
Slide 28 text
A. Avoid excessive calculations
B. Avoid multiple adjustments per line item
Ground Rules
Slide 29
Slide 29 text
http://www.ohloh.net/p/magento
Slide 30
Slide 30 text
No content
Slide 31
Slide 31 text
No content
Slide 32
Slide 32 text
Sales Tax
(it's complicated)
Slide 33
Slide 33 text
Sales Tax
(it's super complicated)
Slide 34
Slide 34 text
New York Sales Tax = ?????
Slide 35
Slide 35 text
"Clothing and footwear
under $110 are exempt
from New York City and
NY State Sales Tax.
!
Purchases above $110
are subject to a 4.5% NYC
Sales Tax and a 4% NY
State Sales Tax."
http://www.nyc.gov/html/dof/html/business/nys_sales_tax.shtml
Slide 36
Slide 36 text
New York Sales Tax = 0%
Slide 37
Slide 37 text
http://www.irishtimes.com/blogs/generationemigration/files/2011/11/australian_flag_3.jpg
10% Goods and Services Tax
Old Adjustments
* Source - Thing doing the adjustment
* Originator - Maybe same as source, maybe not
* Adjustable - Thing being adjusted
* Amount - Self-explanatory
Slide 54
Slide 54 text
Tax Adjustment
* Source = Order
* Originator = TaxRate
* Adjustable = Order
Slide 55
Slide 55 text
Order Tax Rate
create_tax_charge
Slide 56
Slide 56 text
1. tax included in price (i.e. GST)
2. default tax zone is the same as the order's zone
IF
THEN
Purchases in same country as store (price inc.)
Adjustment
Line Item
Line Item
Line Item
Adjustment
Adjustment
1. Apply adjustments to every single line item
1. tax included in price (i.e. VAT)
2. default tax zone is NOT the order's zone
IF
THEN
1. apply one big negative adjustment to the entire order (a refund)
Purchases outside of the country (price inc.)
Adjustment
Order
1. tax is NOT included in price (i.e. sales tax)
THEN
1. apply one big adjustment to the whole order
Purchases in country (price excl.)
Order Adjustment
Order Promotions
* Source = Order
* Originator = PromotionAction
* Adjustable = Order
Slide 89
Slide 89 text
Spree < 2.2 - 10% off promotion
$2 off
Slide 90
Slide 90 text
$2 off
$2 off
Spree < 2.2 - 10% off promotion
1 Order Adjustment for -$4
Slide 91
Slide 91 text
$2 off
$2 off
Spree 2.2+ - 10% off promotion
1 adjustment per line item for -$2
Slide 92
Slide 92 text
Promotion
Handlers
Slide 93
Slide 93 text
Promotion Handlers
Order Promotion
Cart, Coupon, Free Shipping, or Page
Promotion::Handler
New in Spree 2.2!
Slide 94
Slide 94 text
Promotion Handlers
Cart
1. Find all non-code or path promotions
2. Check if they're eligible for that line item or order
3. Activate
Slide 95
Slide 95 text
Promotion Handlers
Coupon
1. Find promotion matching coupon code
2. Validate promotion usage limit & eligiblity
3. Attempt application of promotion to order
4. Report on success of application
Slide 96
Slide 96 text
Promotion Handlers
Free Shipping
1. Find all 'Free Shipping' promotion actions
2. Check eligibility for order
3. Activate
Slide 97
Slide 97 text
Promotion Handlers
Page
1. Find promotion for specified path
2. Check eligibility for order
3. Activate
Slide 98
Slide 98 text
Picking
a winner
Slide 99
Slide 99 text
10% off!
adjustment
LineItem
$10 off!
adjustment
Slide 100
Slide 100 text
$1
LineItem!
@ $10
$10
Slide 101
Slide 101 text
$15
LineItem!
@ $150
$10
Slide 102
Slide 102 text
#4270
Complex promotion rules
Slide 103
Slide 103 text
In summary…
Slide 104
Slide 104 text
"Can I combine
a free shipping promotion
and
a 10% off promotion? "
"You can!"
ORDER SUMMARY
Item Total: $1,599.00
Sales Tax $80.45
-
Free Shipping
Promotion (10% off)
Order Total: $1,511.51
-$167.95
Slide 105
Slide 105 text
PromotionAction::CreateAdjustment
Commandment #1:
Order Wide Adjustments
Slide 106
Slide 106 text
Commandment #2: Discounts + Credits
Yes Not yet
Slide 107
Slide 107 text
Commandment #3: Group discounts
Soon.
Slide 108
Slide 108 text
Commandment #4: Shipping taxation
Yes.
Slide 109
Slide 109 text
Commandment #5: Refunding of items
Soon.
Slide 110
Slide 110 text
Commandment #6: Adjustment freezing
It's always been that way.
Slide 111
Slide 111 text
Commandment #7: VAT Refunding
Of course!
Adjustment
Adjustment
Adjustment
Line Item
Line Item
Line Item
Slide 112
Slide 112 text
Commandment #8: Multiple discounts per order
One promotion adjustment.
One credit adjustment.
One taxation adjustment.
Slide 113
Slide 113 text
Commandment #9: Robust test suite.
Definitely.
Slide 114
Slide 114 text
Commandment A: Avoid excessive calculations.
Calculations at an all time low.
Slide 115
Slide 115 text
Commandment B: Avoid multiple adjustments per item.
Oops.
One promotion adjustment.
One credit adjustment.
One taxation adjustment.
Slide 116
Slide 116 text
Commandment i: Line item adjustments.
One promotion adjustment.
One credit adjustment.
One taxation adjustment.
Slide 117
Slide 117 text
Commandment ii: Some form of inheritance.
Inheritance free zone.
Slide 118
Slide 118 text
Commandment iii: Take advantage of
calculators and rules
Done.
Slide 119
Slide 119 text
Commandment iv: Events should be scrapped.
Gone.
Slide 120
Slide 120 text
Commandment v: Notifications should be scrapped.
Gone.
Replaced with Handlers.
Gone.
Slide 121
Slide 121 text
We now have an adjustments system which is:
SIMPLE
Slide 122
Slide 122 text
We now have an adjustments system which is:
CONSISTENT
Adjustment
LineItem
Shipment Adjustment
Slide 123
Slide 123 text
We now have an adjustments system which is:
FLEXIBLE