Skip to content
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

ProductData for bundle products sends the total bundle price for each child item to API #75

Closed
ThijsdejongSNC opened this issue Oct 14, 2021 · 2 comments
Labels
Fixed in next release This issue is reproduced and the fix will be there in the next release. Reflecting Plugin This is an issue reflecting the plugin

Comments

@ThijsdejongSNC
Copy link

ThijsdejongSNC commented Oct 14, 2021

This happens in Paazl\CheckoutWidget\Model\Api\Builder\Order::getProducts() and Paazl\CheckoutWidget\Model\Handler:Item

Paazl\CheckoutWidget\Model\Handler\Item::getPriceValue uses the quote item parent's (bundle) total value . Paazl\CheckoutWidget\Model\Api\Builder\Order::getProducts() requests this for each child in the bundle.

The consequence of this is that one of our (non eu) customers that ordered a 500 euro bundle with 5 products now got a customs invoice for vat and duties on 2500,- worth of products.

Reproduce by creating a order with bundle for a non-eu country. Check the items in the Paazl backend or check $result on line 177 of Paazl\CheckoutWidget\Model\Api\Builder\Order.

@ThijsdejongSNC
Copy link
Author

ThijsdejongSNC commented Oct 15, 2021

Quick fix for the issue.

diff --git a/Model/Api/Builder/Order.php b/Model/Api/Builder/Order.php
index 1ca6a45..5363a07 100755
--- a/Model/Api/Builder/Order.php
+++ b/Model/Api/Builder/Order.php
@@ -297,7 +297,12 @@ class Order
 
         /** @var Item $item */
         foreach ($order->getItems() as $item) {
-            if ($item->getProductType() !== Type::TYPE_SIMPLE && $item->getProductType() !== Grouped::TYPE_CODE) {
+            if ($item->getProductType() !== Type::TYPE_SIMPLE && $item->getProductType() !== Type::TYPE_BUNDLE && $item->getProductType() !== Grouped::TYPE_CODE) {
+                continue;
+            }
+
+            // Skip a simple product if the parent is a bundle
+            if ($this->hasBundleParent($item)) {
                 continue;
             }
 
@@ -327,6 +332,20 @@ class Order
         return $products;
     }
 
+    /**
+     * Returns true if Quote item has bundle as its parent
+     *
+     * @param $item
+     * @return bool
+     */
+    private function hasBundleParent($item)
+    {
+        if ($item->getParentItemId() > 0) {
+            return $item->getParentItem()->getProductType() === Type::TYPE_BUNDLE;
+        }
+        return false;
+    }
+
     /**
      * @param Item $item
      *

@Frank-Magmodules Frank-Magmodules added Fixed in next release This issue is reproduced and the fix will be there in the next release. Reflecting Plugin This is an issue reflecting the plugin labels Nov 18, 2021
@Frank-Magmodules
Copy link
Collaborator

HI @ThijsdejongSNC , sorry for the late response on this but we've fixed this in an earlier release (version 1.9.2.).
Thank you for your patience and contribution to this. We are closing this issue now but please feel free to reopen the issue if this still occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in next release This issue is reproduced and the fix will be there in the next release. Reflecting Plugin This is an issue reflecting the plugin
Projects
None yet
Development

No branches or pull requests

2 participants