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

mpGiftWrapWrapperRemove does not work #2

Open
pepijnblom opened this issue Feb 26, 2024 · 1 comment
Open

mpGiftWrapWrapperRemove does not work #2

pepijnblom opened this issue Feb 26, 2024 · 1 comment

Comments

@pepijnblom
Copy link

pepijnblom commented Feb 26, 2024

It is currently not possible to remove a wrapper from a cart item

\Mageplaza\GiftWrapGraphQl\Model\Resolver\Wrap\RemoveWrap::handleArgs

    public function remove($cartId, $itemId)
    {
        $this->updateGiftWrap($cartId, $itemId, [], []);

        $item = $this->cartRepository->getActive($cartId)->getItemById($itemId);

        return $this->getWrapItem($item);
    }

Passes an empty array to updateGiftWrap which eventually passes it to \Mageplaza\GiftWrap\Model\Api\QuoteWrap::addWrapOptionToItem which expects an object and then breaks because ->getData() is called

@pepijnblom
Copy link
Author

This patch seems to fix the issue

Index: vendor/mageplaza/module-gift-wrap/Model/Api/QuoteWrap.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/mageplaza/module-gift-wrap/Model/Api/QuoteWrap.php b/vendor/mageplaza/module-gift-wrap/Model/Api/QuoteWrap.php
--- a/vendor/mageplaza/module-gift-wrap/Model/Api/QuoteWrap.php	
+++ b/vendor/mageplaza/module-gift-wrap/Model/Api/QuoteWrap.php	(date 1708941616676)
@@ -131,7 +131,7 @@
     private function addWrapOptionToItem($quote, $itemId, $wrapObj, $wrapDataType)
     {
         $storeId = $quote->getStoreId();
-        $wrap    = $wrapObj->getData();
+        $wrap = !is_array($wrapObj) ? $wrapObj->getData() : $wrapObj;
         if (!empty($wrap[WrapItf::GIFT_MESSAGE])) {
             $maxChars = $this->helper->getMaxCharacters($storeId);
 
@@ -170,7 +170,7 @@
      */
     private function addWrapOption($item, $wrapObj, $wrapDataType)
     {
-        $wrap = $wrapObj->getData();
+        $wrap = !is_array($wrapObj) ? $wrapObj->getData() : $wrapObj;;
         if ($wrap && $wrapObj->getCategory()) {
             $this->helper->validateWrap($wrap);
         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant