73
votes
Accepted
Magento 2 remove "Estimate shipping costs and tax" from cart
I think you messed up some closing / opening tags and amount of them this code works:
<referenceBlock name="checkout.cart.shipping">
<arguments>
<argument name="jsLayout" ...
41
votes
Pop up minicart when I add a product to the cart magento 2
This is my first answer on this site. I've been struggling trying to make this work for the past two days and I was finally able to make it work, so I though it would be nice to share it.
First of ...
34
votes
Magento 2 - How to get all items in cart?
I'll answer the question in two parts:
I. Where should you change the checkout URL?
The destination in link.phtml is $block->getCheckoutUrl(). You should not change the template to change ...
32
votes
Accepted
difference between cart getItemsCount() and getSummaryCount()
Mage::helper('checkout/cart')->getItemsCount() -- return shopping cart items count means how many sku add to shopping cart.
Mage::helper('checkout/cart')->getSummaryCount() -- return shopping ...
29
votes
Magento 2 - How to get all items in cart?
The use of Magento\Checkout\Model\Cart is deprecated.
You should use the session to get the quote and your cart items.
use Magento\Checkout\Model\Session;
public function __construct(
...
...
28
votes
Accepted
programmatically adding product to cart returns empty price
There are many things wrong here and I feel compelled to do a code review with you. See the end for the correct approach.
Code review:
This line is loading a product with an undefined $sku var:
$...
24
votes
Magento 2 - Why is Magento\Checkout\Model\Cart deprecated?
My guess is that the Magento team is planning to implement service contracts for this class.
However as of 2.1 if you check the app/code/Magento/Checkout/Api folder there's no class (yet) that ...
23
votes
How to get all items in cart currently?
There are several methods that work in a different way:
$items = Mage::getSingleton('checkout/cart')->getQuote()->getItemsCollection();
Returns a quote item collection with all items ...
22
votes
Accepted
Magento 2.3.2 Call to undefined function Magento\InventorySales\Model\IsProductSalableForRequestedQtyCondition\bccomp()
bccomp() function belongs to BCMath package; if it's undefined, then possible this library not installed or it's not enabled for your PHP version. Like for php7.2 need to install for ubuntu ...
19
votes
Magento 2 How to remove tax from checkout?
If you want to leave taxes enabled and with a value but just remove them from display remove the item with the name tax at the appropriate place.
For example to remove tax from the checkout cart ...
19
votes
Accepted
How to update minicart view using AJAX?
You can try the below code.
require([
'Magento_Customer/js/customer-data'
], function (customerData) {
var sections = ['cart'];
customerData.invalidate(...
18
votes
Accepted
EE 1.14.2 / CE 1.9.2: Quote items not merged correctly on login (duplicate products in cart)
Nice wrap up of the bug above, Fabian!
For any further users who will come accross this bug, there is already a patch from Magento for this.
As an Enterprise customer, you can request/download ...
18
votes
Magento 2 - How to get all items in cart?
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
// retrieve quote items collection
$itemsCollection = $cart->...
18
votes
Magento 2 - Why is Magento\Checkout\Model\Cart deprecated?
The commit that deprecated the cart model is c4e9a77403655646a18d4277de96429c86bd34fa with the message
MAGETWO-51558: Mark Checkout Cart model as deprecated
This doesn't tell much, especially ...
18
votes
Accepted
How do I load JavaScript function inside KnockoutJS html?
If you need to work with DOM elements, rendered by knockout from this template, you can use afterRender binding.
<div data-bind="afterRender: function() {alert('yes');}"></div>
18
votes
Accepted
Magento 2 : Updating quote item
I am not sure about my below solution:
May be you need to load Quote item object by item id
As you want set price then using setPrice() you cannot set your desire price for that cart item
$item = $...
18
votes
Accepted
Shopping cart is not clearing on the cart page
I've also encountered this issue and I've found out that in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml ~line 27, Magento Team seems missed to put a dot for the 'action' ...
17
votes
Accepted
Terms and condition on checkout page
If you're new to Magento, this answer likely will not make sense. So either get an experienced Magento developer on this or start brushing up. With that, here's what you can try.
Prerequisites
...
17
votes
Accepted
Magento 2 Get Cart Quote Total in minicart.phtml
You have to just keep below line in your minicart.phtml file to get
updated subtotal ,
This Below line is workig for all cases if cache is enable its working fine,
<span data-bind="html: ...
17
votes
Accepted
Get Shipping Price From Quote
This will do the trick. From your question, I assume that the customer has already selected their desired shipping method.
<?php
$quote = Mage::getModel("checkout/session")->getQuote();
$...
16
votes
EE 1.14.2 / CE 1.9.2: Quote items not merged correctly on login (duplicate products in cart)
It turned out that this is a bug in Mage_Sales_Model_Quote_Item::compare() that was introduced in Magento CE 1.9.2 / EE 1.14.2. The method is used to compare items to decide if they are the same ...
16
votes
Magento2 Correct Way to get Order items
This is how the different methods to get items from an order work:
getItems(): returns array of items from loaded order item collection
getAllItems(): returns array of all items that are not marked ...
16
votes
Accepted
Customize sticky behaviour of Cart Summary: Magento 2
I finally found the answer to this. The sticky behavior of the cart summary is due to the code in the file magento_root/vendor/magento/theme-frontend-blank/Magento_Theme/web/js/theme.js.
$('.cart-...
14
votes
Accepted
Auto update cart quantity when change quantity
First edit the cart template /app/design/frontend/{package}/{theme}/template/checkout/cart.phtml and add an id on the form element for easier access. Let's say you add 'id="cart-form"';
Now edit the ...
14
votes
How to add "Buy Now" button in Magento 2.1 Product detail page along with add to cart?
Here is a module that adds a 'Buy Now' button that takes customer directly to checkout with the choosen product in cart.
Module Directory:
| registration.php
|
+---Controller
| \---Cart
| ...
14
votes
Accepted
remove items from cart in controller - magento2
Your custom controller should be:
namespace Gworks\Cart\Controller\Items;
use Magento\Framework\App\Action\Context;
use Magento\Checkout\Model\Cart as CustomerCart;
class Remove extends \Magento\...
14
votes
Accepted
Adding a modal after adding to cart
You can show ajax popup by extending catalog-add-to-cart.js file of Magento-Catalog module.
Steps to do :
1 - Copy catalog-add-to-cart.js from '\module-catalog\view\frontend\web\js/catalog-add-to-...
13
votes
Accepted
Cart Summary expanded
To make cart summary opened initially on page load do the following :
Go to your core files and copy cart-items.html
vendor/magento/module-checkout/view/frontend/web/template/summary/cart-items....
12
votes
Accepted
Getting quote (cart) items programatically shows duplicate SKUs for both the configurable and simple product
According to Magento, when a configurable product added at cart then two rows are inserted at the database. one configurable product cart another is a simple product
One row has configurable id and ...
12
votes
Accepted
How to get total discount amount of Coupon Code for all items in the cart
$quote2 = Mage::getSingleton('checkout/session')->getQuote();
$discountTotal = 0;
foreach ($quote2->getAllItems() as $item){
$discountTotal += $item->getDiscountAmount();
}
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
cart × 2200magento2 × 759
magento-1.9 × 435
checkout × 355
addtocart × 193
product × 166
shopping-cart × 142
quote × 139
magento-2.1 × 107
event-observer × 94
mini-cart × 85
shipping × 82
magento-1.7 × 80
shopping-cart-price-rules × 80
price × 79
custom-options × 68
configurable-product × 65
ajax × 63
magento-1.8 × 60
magento2.3 × 58
php × 53
onepage-checkout × 52
session × 51
tax × 48
magento-1 × 47