You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #16, and associated PR #17, fixes were added to ensure that free gifts are not added to the cart during re-order.
This functionality is not working on Magento 2.4.4. I've not figured out quite when this broke, but I suspect the Magento core reorder code changed at some point.
Suggested solution
We have deployed the following code, which we suggest probably should be moved into this extension:
namespace Vendor\SmileGiftSalesRule\Plugin\Quote\Model;
use Magento\Quote\Model\Quote as Subject;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Framework\DataObject;
use Magento\Framework\App\RequestInterface;
class Quote
{
public function __construct(
protected RequestInterface $request
) {
}
/**
* Avoid to add a gift product when adding an order item.
* Avoids the re-ordering of gift-items.
*
* sales_order_reorder: Front-end re-orders
* sales_order_create_reorder: Admin re-orders
*
* Smile used to handle this out the box in `magento2-module-gift-sales-rule/Plugin/Checkout/Model/Cart.php`,
* but that logic doesn't work with the latest versions of Magento.
* This code is based on that logic.
*
* @param Subject $subject Subject
* @param \Closure $proceed Parent method
* @param ProductInterface $orderItem Order item
* @param DataObject $request Quantity flag
*
* @return Subject
*/
public function aroundAddProduct(
Subject $subject,
\Closure $proceed,
$orderItem,
$request = null
) {
if ((isset($request['gift_rule']) && $request['gift_rule']) &&
(in_array($this->request->getFullActionName(), ['sales_order_reorder', 'sales_order_create_reorder'], true))
) {
return null;
}
return $proceed($orderItem, $request);
}
}
The text was updated successfully, but these errors were encountered:
In #16, and associated PR #17, fixes were added to ensure that free gifts are not added to the cart during re-order.
This functionality is not working on Magento 2.4.4. I've not figured out quite when this broke, but I suspect the Magento core reorder code changed at some point.
Suggested solution
We have deployed the following code, which we suggest probably should be moved into this extension:
The text was updated successfully, but these errors were encountered: