Skip to content

Commit

Permalink
Merge pull request #58 from jgodson/revert-55-feature/tiered_discount…
Browse files Browse the repository at this point in the history
…_cart_discounted_subtotal

Revert "Added cart discounted subtotal tier type option in tiered discount"
  • Loading branch information
jgodson authored Apr 21, 2022
2 parents cabd5e4 + ac3eed7 commit d41e169
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 55 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "shopify-script-creator",
"private": true,
"version": "0.31.0",
"version": "0.30.0",
"description": "Shopify Script Creator",
"main": "index.js",
"scripts": {
Expand Down
24 changes: 0 additions & 24 deletions ruby_scripts/lineItem/tiered_discount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,6 @@ def run(cart)
when :cart_subtotal
cart_total = cart.subtotal_price
qualified_tiers = @discount_tiers.select { |tier| cart_total >= Money.new(cents: tier[:tier].to_i * 100) }
when :cart_discounted_subtotal
cart_total =
case cart.discount_code
when CartDiscount::Percentage
if cart.subtotal_price >= cart.discount_code.minimum_order_amount
cart_subtotal_without_gc = cart.line_items.reduce(Money.zero) do |total, item|
total + (item.variant.product.gift_card? ? Money.zero : item.line_price)
end
gift_card_amount = cart.subtotal_price - cart_subtotal_without_gc
cart_subtotal_without_gc * ((Decimal.new(100) - cart.discount_code.percentage) / 100) + gift_card_amount
else
cart.subtotal_price
end
when CartDiscount::FixedAmount
if cart.subtotal_price >= cart.discount_code.minimum_order_amount
[cart.subtotal_price - cart.discount_code.amount, Money.zero].max
else
cart.subtotal_price
end
else
cart.subtotal_price
end
end
qualified_tiers = @discount_tiers.select { |tier| cart_total >= Money.new(cents: tier[:tier].to_i * 100) }
when :discountable_total
discountable_total = applicable_items.reduce(Money.zero) { |total, item| total + item.line_price }
qualified_tiers = @discount_tiers.select { |tier| discountable_total >= Money.new(cents: tier[:tier].to_i * 100) }
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChangeLogContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function ChangeLogContent({newVersion} = props) {
<h3 id="changelog">Change Log</h3>

<ul>
<li>Added cart discounted subtotal tier type option in tiered discount.</li>
<li>Added a comment at the top of generated scripts to indicate that they were generated by the Script Creator.</li>
</ul>

<div style={{paddingTop: '2rem'}}>
Expand Down
28 changes: 0 additions & 28 deletions src/scripts/lineItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,30 +591,6 @@ class TieredDiscount < Campaign
when :cart_subtotal
cart_total = cart.subtotal_price
qualified_tiers = @discount_tiers.select { |tier| cart_total >= Money.new(cents: tier[:tier].to_i * 100) }
when :cart_discounted_subtotal
cart_total =
case cart.discount_code
when CartDiscount::Percentage
if cart.subtotal_price >= cart.discount_code.minimum_order_amount
cart_subtotal_without_gc = cart.line_items.reduce(Money.zero) do |total, item|
total + (item.variant.product.gift_card? ? Money.zero : item.line_price)
end
gift_card_amount = cart.subtotal_price - cart_subtotal_without_gc
cart_subtotal_without_gc * ((Decimal.new(100) - cart.discount_code.percentage) / 100) + gift_card_amount
else
cart.subtotal_price
end
when CartDiscount::FixedAmount
if cart.subtotal_price >= cart.discount_code.minimum_order_amount
[cart.subtotal_price - cart.discount_code.amount, Money.zero].max
else
cart.subtotal_price
end
else
cart.subtotal_price
end
end
qualified_tiers = @discount_tiers.select { |tier| cart_total >= Money.new(cents: tier[:tier].to_i * 100) }
when :discountable_total
discountable_total = applicable_items.reduce(Money.zero) { |total, item| total + item.line_price }
qualified_tiers = @discount_tiers.select { |tier| discountable_total >= Money.new(cents: tier[:tier].to_i * 100) }
Expand Down Expand Up @@ -1102,10 +1078,6 @@ const campaigns = [{
value: "cart_subtotal",
label: "Cart Subtotal"
},
{
value: "cart_discounted_subtotal",
label: "Cart Discounted Subtotal"
},
{
value: "cart_items",
label: "Cart Items Total Quantity"
Expand Down
2 changes: 1 addition & 1 deletion src/versions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
currentVersion: "0.31.0",
currentVersion: "0.30.0",
minimumVersion: "0.1.0",
}

0 comments on commit d41e169

Please sign in to comment.