exclude product from cart spend restrictions: yith-woocommerce

I’m using a minimum-maximum plugin for woocommerce from yith. say I have 3 categories of paper, pens, and mugs. paper generally costs $10, pens generally $5, and mugs generally $50.

now I set a cart spend minimum of $100 but I want to exclude pens from the cart spend minimum. even after setting it up in the backend, I still cannot checkout pens because it claims the cart spend of $100 has not been reached.

if anyone has experienced this and has a workaround, please help.

javascript – Node.js/Express.js: How can I update a user’s cart with post, but not delete the rest of the users from the JSON file? (overwrites everything)

Explanation of other methods. Everything is correct with those when I log their functinality in the console 🙂 :

  1. getById(): finds the index of the product that I pass from my endpoints. This method has also a readFile integrated in it to read the products file. There are 2 different files. One holding the users and one holding the products.
  2. getAll(): Reads the users JSON file.

=> As you can see the product is added by the productId in the user’s cart but it overwrites and deletes every other user. I have tried a lot of things like using operators, having different methods but I am kinda stuck for hours. If I do the same without the 2 last lines to write in the file, the product is added but of course it’s not saved.

My method in my model looks like that:

export async function addProductToCart(id, productId) {
  let users = await getAll();
  if (users) {
    let index = await getByID(productId);
    let productIdFinder = index.productId;
    const filteredUsers = users.filter((user) => user.UserId === id);

    let userCart = filteredUsers(0).cart.products;
    userCart.push(productIdFinder);
    
    let productArrayString = JSON.stringify(filteredUsers);
    fs.writeFile(USERS_FILE, productArrayString);
  }
}

My method in my controller looks like that:

export async function addP(req,res){
  try{
    const userId =parseInt(req.params.id);
    const productId = parseInt(req.params.pid);
    // await getCartUser(userId);
    await addProductToCart(userId, productId);
    res.json({productAdded:productId});
  } catch(error){
    res.status(400).send(error.message);
  }
}

My method in my routeslooks like that: (Also tried put)

router.route("/:id/add/:pid").post(addP);

Screenshots before and after sending the request:

POST http://localhost:3000/api/users/3/add/2 HTTP/1.1

enter image description here

enter image description here

magento2 – Product package with quantity 0 continues to appear in the cart

Guys I need help with something in magento, I look everywhere and I couldn’t solve it and since I’m a novice I decided to resort to you. On the page of bundle products when setting the input of a product to 0 and clicking on buy it continues to appear in the cart. How can I solve this? I need to resolve this and I need help.

enter image description here

enter image description here

magento2.3 – Magento 2 Cross Sell products layout are breaking in shopping cart page even in default Theme

We are facing a issue with the Cross Sell products layout in shopping cart page.

The product items that are rendered are not loading in proper HTML structure and resulting the items layout to beak.

The product Items are rendered from the below file path, and the same will load in PDP page as well. But in PDP page it loads perfectly fine. Only in cart part we are facing this issue.

  • vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml

We have custom theme but to confirm we switched to Luma and Blank theme. Even in Magento default theme we are facing this issue.

Please help !

I have attached a few screenshots that can explain the issue better.

1. HTML Inspect
enter image description here

2. Frontend
enter image description here

magento2.4 – Prevent cart empty before connecting to payment

Currently in Magrnto 2 before connecting to payment gateway, the in the quote table the is_active status is becoming zero and a new dummy record is created in the same table. So, if the customer not completing the order, and left right from the payment page, the cart becomes empty on his next visit.

I would like to prevent this. hence, I have added a plugin in di.xml as below,

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoSalesApiOrderManagementInterface">
        <plugin name="ucs_making_the_cart_alive" type="UcsActiveCartPluginOrderServicePlugin" sortOrder="5"/>
    </type>
</config>

And in the plugin added a afterPlace method as below,

<?php

namespace UcsActiveCartPlugin;

use MagentoSalesApiDataOrderInterface;
use MagentoSalesApiOrderManagementInterface;
use MagentoSalesApiOrderRepositoryInterface;

class OrderServicePlugin
{
    protected $_orderRepository;
    protected $_quoteRepository;


    protected $_quoteFactory;
    protected $_quoteModel;

    public function __construct(
        OrderRepositoryInterface $OrderRepositoryInterface,
        MagentoQuoteModelQuoteRepository $quoteRepository,
        
        MagentoQuoteModelQuoteFactory $quoteFactory,
        MagentoQuoteModelResourceModelQuote $quoteModel,

        MagentoFrameworkAppActionContext $context
    )
    {
        $this->_orderRepository = $OrderRepositoryInterface;
        $this->_quoteRepository = $quoteRepository;


        $this->_quoteFactory = $quoteFactory;
        $this->_quoteModel=$quoteModel;

    }
    public function afterPlace( 
        OrderManagementInterface $subject,
        OrderInterface $result
    ) {
        //$return = $proceed($order);

        $order_increment_id = $result->getIncrementId();
        $order_id = $result->getEntityId();

        //$order_id = $order->getEntityId();

        $log_date = date('d-m-Y');

        /* START : BELOW LOG IS USED TO CAPTUE THE RECEIVED AND RESPONDED DATE */
        $log_file = '/var/log/plugin-cart-active-'.$log_date.'.log';
        $writer = new ZendLogWriterStream(BP . $log_file);
        $logger = new ZendLogLogger();
        $logger->addWriter($writer);


        $logger->info($order_increment_id);
        $logger->info($order_id);
        /* END : BELOW LOG IS USED TO CAPTUE THE RECEIVED AND RESPONDED DATE */

        
        try {

            $order = $this->_orderRepository->get($order_id);

            $logger->info('Making the quote process active before payment process begins for the order entity id ->'.$order_id);
            
            $quote_id = $order->getQuoteId();

            $logger->info('Quote ID for the order has been deducted as ->'.$quote_id);

            $quote = $this->_quoteRepository->get($quote_id); // Get quote by id
            $quote->setIsActive(1)->setReservedOrderId(null)->save();


            $quote->setData('is_payment_initiated', 1); // Fill data
            $logger->info(json_encode($quote->getData()));
            $this->_quoteRepository->save($quote); // Save quote
            $logger->info('Quote Saved');

            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $_checkoutSession = $objectManager->create('MagentoCheckoutModelSession');
            $_checkoutSession->replaceQuote($quote);

        } catch (Exception $e) {
            $logger->info('Error in updation process');
            $logger->info($e->getMessage());
        }

        return $result;

    }
}

But still the is_active status is not becoming active. What happens is the logic works but only after that the dummy record creation and making the actual is_active status becoming zero process is happening.

How can I override this behavior?

php – Get attribute label on cart page Woocommerce

Issue/Desired Result

I want to get the attribute_label on the cart page of my Woocommerce store, for example, ‘Size’. My current code is giving me the slug, for example, ‘Attribute_size’.

How can I update my code to get the attribute label?

cart.php Code

// Meta data
    if (!empty($cart_item('variation'))) {
        echo '<div class="variation">';
            foreach ($cart_item('variation') as $key => $variation) {
                echo '<div><span>' . ucwords(str_replace(array('pa_', '-2'), '', $key)) . ':</span>
        <p>' . $variation . '</p></div>';
                                    }
                                echo '</div>';
                            }

plugins – Easy Digital Downloads – Cart not working on AWS hosting

We have a site hosted on AWS. But, the Easy Digital Downloads cart is not working properly. Items added to cart disappears and the items are not removed as well. Also, there is no any cache plugin installed. There are only some basic plugins installed and there is no error on browser console.

Can someone hopefully shed some light on this?

Thank you.

magento2 – How to update a Magento 2 cart?

Maybe I don’t know enough about Magento, but is there not a setting for allowing a cart update?

I have a Magento 2.3 site, and when I add items to the cart, it opens up a minicart with the quantities. But, when I close the minicart, and then go back to the cart and update the quantities, it end ups doubling all the quantities, instead of just updating what has been changed.

Is there not an “update cart” option built into Magento?

Info_buyrequest not loading after editing quote on cart configure product page

I am running magento 2.3 using Redis as cache. When an item it added to the basket I store additional info into info_buyRequest. If I then goto the cart page and select edit I get sent to the cart configure page (product_page) but the contents of info_buyrequest is blank. If I reload the cart configure page then I see the Params saved in the info_buyrequest array. I thought at first magento was reloading a cached version of the product page but I can see the Item->Id.