How to limit the number of gift items in the cart? - magento2.4

I am new to Magento, I have a task to add an item to the cart to 1 purchased item + 1 gift item. But in the gift basket can only be 1. I can not find how to do it right. Help me please.

Related

How to apply shopping cart rule for single product?

we want a discount to be applied when user add to cart 10 M size t-shirts, 10 L size t-shirts and 5 XL size t-shirts (same product) - so total quantity is 25. & we want to give discount only for the product whose quality is 25 or greater?
You can try to create "Shopping Cart Price Rule" with condition on "Quantity in Cart". Does it help you?

How to create this Magento Shopping Cart Price Rule?

Offers FREE SHIPPING only to products with a product attribute (in_stock) to YES and the subtotal of such items must be greater than $99. Rules apply to matching items only.
For example,
item A $80 in stock
item B $20 in stock
Results: FREE SHIPPING
item A $80 in stock
item B $20 in stock
item C $30 out of stock
Results: SHIPPING COST FOR ITEM C ONLY
item A $100 in stock
Results: FREE SHIPPING
item C $30 out of stock
item A $80 in stock
RESULTS: SHIPPING COST FOR BOTH item A and C.
hi please make this type rules for this functionality, you change just use product attribute 'stock-availability' in condition with sku-id's.
you will check rules here:-
https://www.dropbox.com/s/7t8c5qiznkjgz13/Free%20Shipping%20for%20Single%20Product%20Using%20Shopping%20Cart%20Price%20Rules.docx?dl=0

magento i need to apply discount 20% for the total if above 50euros but not to the discounted items

magento i need to apply discount 20% for the total if above 50euros but not to the discounted items if customers selects some already discounted items that should not include in the total can any one help
Thanks in advance
You need to create a custom module or say shopping cart price rule and an event observer to check whether the "special price" is zero or not. If it is "Zero" that means it is not a already discounted product or you can even check the "final price" with the "price" , if the final price is lesser than price it is already discounted.
If these conditions are satisfied get the prices of remaining products prices and discount them then add the already discounted products price to make the total amount.
I hope You understood this concept and write your own module.
you have to use a check in view page.
for example
$price = $product->getPrice();
$specialprice = $product->getFinalPrice();
if(!empty($specialprice)){
//then your price would be same
}
elseif(empty($specialprice)){
then price would be = $price*20/100;
}
hope this would help you and don't forget to like if it was helpful

Modify Magento Subtotal Calculation: Tier prices

I am using Tier Prices and have a set price for quantities that fall between 1 and 4 and a per item price for anything over 4.
I want to modify my cart to have a set price for items where Qty >= 1 && Qty <=4
How do I do that?
Here is the item i testing this with: http://stjamestutorials.com/ppptransportation/index.php/mayfield-falls-tours-negril-jamaica-tours.html
Try and create an observer for this event:
catalog_product_get_final_price
which is found in the class :
app\code\core\Mage\Catalog\Model\Product\Type\Price.php
The event comes with the product and the qty, so you can write your logic and then set your custom price in the final_price attribute of the product.

is it possible to get only the associated product count from shopping cart?

I am working on a Ajax cart for my website. I am trying to validate Configurable products for the stock availability. Please consider below case
Cotton shirt (Product ID : 421 - Configurable Product)
Size : L (Product ID : 425 - Simple product)
Size : M (Product ID : 436 - Simple product)
User should select at least one size to add product to the cart.
When i added this product with "Size L" twice and added this product with "Size M" once.
And when i print the item ids in shopping cart, it shows only the id of Configurable product (421).
How do i get ids of Simple product which are really being added to the cart?
You will need to check if the product in the cart is configurable, then if it is you can get the information stored in the product options to work out the simple product that was actually added. The below code should help a bit:
if($product['product_type']=='configurable'){
$options = unserialize($product['product_options']);
$simpleProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',$options['simple_sku']);
}

Resources