-
Couldn't load subscription status.
- Fork 40
adding gift card support for underarmour #504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: magic_integration_latest
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -192,6 +192,11 @@ public function execute() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $resultJson = $this->resultJsonFactory->create(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $giftCardDiscountAmount = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //Check if the customer has applied GiftCards | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if($quote->getMageworxGiftcardsAmount()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $giftCardDiscountAmount = abs($quote->getMageworxGiftcardsAmount()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $maskedId = $this->maskedQuoteIdInterface->execute($quoteId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ($maskedId === '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -240,6 +245,7 @@ public function execute() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $productUrl = $product->getProductUrl(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $offerPrice = $quoteItem->getPrice() * 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check if the item has applied discounts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ($quoteItem->getDiscountAmount()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Get the discount amount applied to the item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -323,6 +329,20 @@ public function execute() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $orderNotes = array_merge($orderNotes, $customerEmailNotes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if($giftCardDiscountAmount > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $totalAmount = $totalAmount - $giftCardDiscountAmount; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $giftCardDiscount = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'gift_card_discount'=> $giftCardDiscountAmount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $orderNotes = array_merge($orderNotes, $giftCardDiscount); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $promotions = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'type' => 'gift_card', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'code' => 'gift_card_number', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'value' => $giftCardDiscountAmount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'description' => 'applied', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+332
to
+345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When there's no Gift Card Discount applied, I believe the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $razorpay_order = $this->rzp->order->create([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'amount' => $totalAmount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -332,7 +352,8 @@ public function execute() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'app_offer' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'notes' => $orderNotes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'line_items_total' => $totalAmount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'line_items' => $lineItems | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'line_items' => $lineItems, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'promotions' => $promotions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (null !== $razorpay_order && !empty($razorpay_order->id)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -348,7 +369,8 @@ public function execute() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'allow_coupon_application' => $allowCouponApplication == 1 ? true : false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'rzp_order_id' => $razorpay_order->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'items' => $items, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'message' => 'Razorpay Order created successfully' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'message' => 'Razorpay Order created successfully', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you considered using |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'gift_card_discount' => $giftCardDiscount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $orderLink = $this->_objectManager->get('Razorpay\Magento\Model\OrderLink') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified with: