code4business / freeproduct2

Magento2 extension that allows creating sales rules that add gift products.
64 stars 28 forks source link

Error when using with Multiaddress(shipment) orders #6

Closed krwilliamssp closed 6 years ago

krwilliamssp commented 6 years ago

Kyles-MacBook-Pro-3:smokehouse kylewilliams$ cat var/report/322295003973 {"0":"Warning: Invalid argument supplied for foreach() in \/Users\/kylewilliams\/Sites\/smokehouse\/app\/code\/C4B\/FreeProduct\/Observer\/ResetGiftItems.php on line 59","1":"#0 \/Users\/kylewilliams\/Sites\/smokehouse\/app\/code\/C4B\/FreeProduct\/Observer\/ResetGiftItems.php(59): Magento\Framework\App\ErrorHandler->handler(2, 'Invalid argumen...', '\/Users\/kylewill...', 59, Array)\n#1 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php(72): C4B\FreeProduct\Observer\ResetGiftItems->execute(Object(Magento\Framework\Event\Observer))\n#2 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(C4B\FreeProduct\Observer\ResetGiftItems), Object(Magento\Framework\Event\Observer))\n#3 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-staging\/Model\/Event\/Manager.php(97): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))\n#4 \/Users\/kylewilliams\/Sites\/smokehouse\/generated\/code\/Magento\/Staging\/Model\/Event\/Manager\/Proxy.php(95): Magento\Staging\Model\Event\Manager->dispatch('sales_quote_add...', Array)\n#5 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-quote\/Model\/Quote\/TotalsCollector.php(259): Magento\Staging\Model\Event\Manager\Proxy->dispatch('sales_quote_add...', Array)\n#6 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-quote\/Model\/Quote\/TotalsCollector.php(144): Magento\Quote\Model\Quote\TotalsCollector->collectAddressTotals(Object(Magento\Quote\Model\Quote\Interceptor), Object(Magento\Quote\Model\Quote\Address\Interceptor))\n#7 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magent

domeglic commented 6 years ago

Which version are you using?

krwilliamssp commented 6 years ago

Hello!

Magento 2.2.5 EE 1.0.4 FreeProduct.

I setup a CPR for free product and get this on multiple shipment order

{"0":"Warning: Invalid argument supplied for foreach() in \/Users\/kylewilliams\/Sites\/smokehouse\/app\/code\/C4B\/FreeProduct\/Observer\/ResetGiftItems.php on line 75","1":"#0 \/Users\/kylewilliams\/Sites\/smokehouse\/app\/code\/C4B\/FreeProduct\/Observer\/ResetGiftItems.php(75): Magento\Framework\App\ErrorHandler->handler(2, 'Invalid argumen...', '\/Users\/kylewill...', 75, Array)\n#1 \/Users\/kylewilliams\/Sites\/smokehouse\/app\/code\/C4B\/FreeProduct\/Observer\/ResetGiftItems.php(44): C4B\FreeProduct\Observer\ResetGiftItems->removeOldGiftQuoteItems(Object(Magento\Quote\Model\ShippingAssignment))\n#2 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php(72): C4B\FreeProduct\Observer\ResetGiftItems->execute(Object(Magento\Framework\Event\Observer))\n#3 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(C4B\FreeProduct\Observer\ResetGiftItems), Object(Magento\Framework\Event\Observer))\n#4 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-staging\/Model\/Event\/Manager.php(97): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))\n#5 \/Users\/kylewilliams\/Sites\/smokehouse\/generated\/code\/Magento\/Staging\/Model\/Event\/Manager\/Proxy.php(95): Magento\Staging\Model\Event\Manager->dispatch('sales_quote_add...', Array)\n#6 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-quote\/Model\/Quote\/TotalsCollector.php(259): Magento\Staging\Model\Event\Manager\Proxy->dispatch('sales_quote_add...', Array)\n#7 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-quote\/Model\/Quote\/TotalsCollector.php(144): Magento\Quote\Model\Quote\TotalsCollector->collectAddressTotals(Object(Magento\Quote\Model\Quote\Interceptor), Object(Magento\Quote\Model\Quote\Address\Interceptor))\n#8 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Quote\Model\Quote\TotalsCollector->collect(Object(Magento\Quote\Model\Quote\Interceptor))\n#9 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\Quote\Model\Quote\TotalsCollector\Interceptor->callParent('collect', Array)\n#10 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\Quote\Model\Quote\TotalsCollector\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Quote\Model\Quote\Interceptor))\n#11 \/Users\/kylewilliams\/Sites\/smokehouse\/generated\/code\/Magento\/Quote\/Model\/Quote\/TotalsCollector\/Interceptor.php(26): Magento\Quote\Model\Quote\TotalsCollector\Interceptor->callPlugins('collect', Array, Array)\n#12 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-quote\/Model\/Quote.php(1959): Magento\Quote\Model\Quote\TotalsCollector\Interceptor->collect(Object(Magento\Quote\Model\Quote\Interceptor))\n#13 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-multishipping\/Model\/Checkout\/Type\/Multishipping.php(873): Magento\Quote\Model\Quote->collectTotals()\n#14 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Multishipping\Model\Checkout\Type\Multishipping->save()\n#15 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\Multishipping\Model\Checkout\Type\Multishipping\Interceptor->callParent('save', Array)\n#16 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\Multishipping\Model\Checkout\Type\Multishipping\Interceptor->Magento\Framework\Interception\{closure}()\n#17 \/Users\/kylewilliams\/Sites\/smokehouse\/generated\/code\/Magento\/Multishipping\/Model\/Checkout\/Type\/Multishipping\/Interceptor.php(39): Magento\Multishipping\Model\Checkout\Type\Multishipping\Interceptor->callPlugins('save', Array, Array)\n#18 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-multishipping\/Model\/Checkout\/Type\/Multishipping.php(333): Magento\Multishipping\Model\Checkout\Type\Multishipping\Interceptor->save()\n#19 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-multishipping\/Model\/Checkout\/Type\/Multishipping.php(270): Magento\Multishipping\Model\Checkout\Type\Multishipping->_init()\n#20 \/Users\/kylewilliams\/Sites\/smokehouse\/generated\/code\/Magento\/Multishipping\/Model\/Checkout\/Type\/Multishipping\/Interceptor.php(14): Magento\Multishipping\Model\Checkout\Type\Multishipping->construct(Object(Magento\Checkout\Model\Session\Interceptor), Object(Magento\Customer\Model\Session\Interceptor), Object(Magento\Sales\Model\OrderFactory), Object(Magento\Customer\Model\ResourceModel\AddressRepository), Object(Magento\Staging\Model\Event\Manager\Proxy), Object(Magento\Framework\App\Config), Object(Magento\Framework\Session\Generic\Interceptor), Object(Magento\Quote\Model\Quote\AddressFactory), Object(Magento\Quote\Model\Quote\Address\ToOrder\Interceptor), Object(Magento\Quote\Model\Quote\Address\ToOrderAddress\Interceptor), Object(Magento\Quote\Model\Quote\Payment\ToOrderPayment), Object(Magento\Quote\Model\Quote\Item\ToOrderItem\Interceptor), Object(Magento\Store\Model\StoreManager\Interceptor), Object(Magento\Payment\Model\Method\Specification\Composite), Object(Magento\Multishipping\Helper\Data), Object(Magento\Sales\Model\Order\Email\Sender\OrderSender), Object(Magento\Directory\Model\PriceCurrency), Object(Magento\Quote\Model\QuoteRepository\Interceptor), Object(Magento\Framework\Api\SearchCriteriaBuilder), Object(Magento\Framework\Api\FilterBuilder), Object(Magento\Quote\Model\Quote\TotalsCollector\Interceptor), Array, NULL, NULL, NULL, NULL, NULL)\n#21 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php(111): Magento\Multishipping\Model\Checkout\Type\Multishipping\Interceptor->construct(Object(Magento\Checkout\Model\Session\Interceptor), Object(Magento\Customer\Model\Session\Interceptor), Object(Magento\Sales\Model\OrderFactory), Object(Magento\Customer\Model\ResourceModel\AddressRepository), Object(Magento\Staging\Model\Event\Manager\Proxy), Object(Magento\Framework\App\Config), Object(Magento\Framework\Session\Generic\Interceptor), Object(Magento\Quote\Model\Quote\AddressFactory), Object(Magento\Quote\Model\Quote\Address\ToOrder\Interceptor), Object(Magento\Quote\Model\Quote\Address\ToOrderAddress\Interceptor), Object(Magento\Quote\Model\Quote\Payment\ToOrderPayment), Object(Magento\Quote\Model\Quote\Item\ToOrderItem\Interceptor), Object(Magento\Store\Model\StoreManager\Interceptor), Object(Magento\Payment\Model\Method\Specification\Composite), Object(Magento\Multishipping\Helper\Data), Object(Magento\Sales\Model\Order\Email\Sender\OrderSender), Object(Magento\Directory\Model\PriceCurrency), Object(Magento\Quote\Model\QuoteRepository\Interceptor), Object(Magento\Framework\Api\SearchCriteriaBuilder), Object(Magento\Framework\Api\FilterBuilder), Object(Magento\Quote\Model\Quote\TotalsCollector\Interceptor), Array, NULL, NULL, NULL, NULL, NULL)\n#22 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/ObjectManager\/Factory\/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Multish...', Array)\n#23 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/ObjectManager\/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Multish...')\n#24 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-multishipping\/Controller\/Checkout.php(49): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Multish...')\n#25 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-multishipping\/Controller\/Checkout.php(155): Magento\Multishipping\Controller\Checkout->_getCheckout()\n#26 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Multishipping\Controller\Checkout->dispatch(Object(Magento\Framework\App\Request\Http))\n#27 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\Multishipping\Controller\Checkout\Index\Interceptor->callParent('dispatch', Array)\n#28 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-customer-segment\/Model\/App\/Action\/ContextPlugin.php(81): Magento\Multishipping\Controller\Checkout\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#29 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\CustomerSegment\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Multishipping\Controller\Checkout\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#30 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\Multishipping\Controller\Checkout\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#31 \/Users\/kylewilliams\/Sites\/smokehouse\/generated\/code\/Magento\/Multishipping\/Controller\/Checkout\/Index\/Interceptor.php(26): Magento\Multishipping\Controller\Checkout\Index\Interceptor->callPlugins('dispatch', Array, Array)\n#32 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/App\/FrontController.php(55): Magento\Multishipping\Controller\Checkout\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#33 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))\n#34 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->callParent('dispatch', Array)\n#35 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-store\/App\/FrontController\/Plugin\/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#36 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#37 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/module-page-cache\/Model\/App\/FrontController\/BuiltinPlugin.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#38 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#39 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/amasty\/aminvisiblecaptcha\/Plugin\/Predispatch.php(93): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#40 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Amasty\InvisibleCaptcha\Plugin\Predispatch->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#41 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#42 \/Users\/kylewilliams\/Sites\/smokehouse\/generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->callPlugins('dispatch', Array, NULL)\n#43 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/App\/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#44 \/Users\/kylewilliams\/Sites\/smokehouse\/vendor\/magento\/framework\/App\/Bootstrap.php(256): Magento\Framework\App\Http->launch()\n#45 \/Users\/kylewilliams\/Sites\/smokehouse\/pub\/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#46 {main}","url":"\/multishipping\/checkout\/","script_name":"\/index.php"}

domeglic commented 6 years ago

It seems like $quoteItem->getOptions() here doesn't return an array which is strange. The solution is probably just a check for array, i will have a look into it.

krwilliamssp commented 6 years ago

ok great. this works on normal checkout btw. Just multiple address/shipment checkout

On Mon, Aug 20, 2018 at 7:59 AM Dominik Meglič notifications@github.com wrote:

It seems like $quoteItem->getOptions() here https://github.com/code4business/freeproduct2/blob/master/Observer/ResetGiftItems.php#L75 doesn't return an array which is strange. The solution is probably just a check for array, i will have a look into it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/code4business/freeproduct2/issues/6#issuecomment-414325942, or mute the thread https://github.com/notifications/unsubscribe-auth/AYGdCSnLhPsiZe51CGh4DTfKpqKldQhxks5uSsDJgaJpZM4WDUX0 .

-- Kyle Williams Motion Trap | Booking & Marketing FACEBOOK http://facebook.com/motiontrap | SOUNDCLOUD http://soundcloud.com/motiontrap | EPK https://www.reverbnation.com/rpk/motiontrapmusic | Molecule - Music Video https://www.youtube.com/watch?v=-BOnZD2s9ng | Youth Blood - Music Video https://www.youtube.com/watch?v=-2fa9_dMrlE

Motion Trap makes sonic exploration dance music. An escalating interplay between electronic-tinged riffs, infectious melodies, and rhythmic leads to a state of wonder. Dreamy, but not hazy, more like the feeling of being in the moment and letting it all wash over you. All while the beat forever propels you forward.

domeglic commented 6 years ago

We never really used multishipping, I see there are some issues with it even after fixing the bug you mentioned.

krwilliamssp commented 6 years ago

Bummer!

Is there plans to fix on your roadmap?

On Fri, Aug 24, 2018 at 1:31 AM Dominik Meglič notifications@github.com wrote:

We never really used multishipping, I see there are some issues with it even after fixing the bug you mentioned.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/code4business/freeproduct2/issues/6#issuecomment-415677136, or mute the thread https://github.com/notifications/unsubscribe-auth/AYGdCdqffU25dlmIvaBnBVNB7d9eP0BFks5uT6vkgaJpZM4WDUX0 .

-- Kyle Williams Motion Trap | Booking & Marketing FACEBOOK http://facebook.com/motiontrap | SOUNDCLOUD http://soundcloud.com/motiontrap | EPK https://www.reverbnation.com/rpk/motiontrapmusic | Molecule - Music Video https://www.youtube.com/watch?v=-BOnZD2s9ng | Youth Blood - Music Video https://www.youtube.com/watch?v=-2fa9_dMrlE

Motion Trap makes sonic exploration dance music. An escalating interplay between electronic-tinged riffs, infectious melodies, and rhythmic leads to a state of wonder. Dreamy, but not hazy, more like the feeling of being in the moment and letting it all wash over you. All while the beat forever propels you forward.

domeglic commented 6 years ago

Sorry for the late reply, we do not plan to fix multishipping at this time.