Sales promotion not removed when required items removed - magento

We have an issue with our site where if you add items in a promotion (eg. buy x and y and get z% off y), then remove one of the items (x) you still get the discount (on y). I'm a bit of a self taught noob when it comes to magento and PHP so I don't even know where I would look, does anyone have any ideas?

Just check once again all the conditions and actions applied for that promotion.
Discount might be still there because of that reason also.

Ok so it turns out the colleague who set the promotion up put the affected items in both sets of conditions - should have checked there first!

Related

How Do I Limit A Script To Execute Once Per Customer? Script Editor and Shopify

What I want:
I have created a script in the Script Editor that makes your first
line item in a cart free. I want this script to execute once per customer.
My question:
What is the syntax to limit a script to execute once per customer
through the use of the Script Editor app?
Business use case:
Without adding this functionality to my script, a customer could
checkout with 1 item free... but then they could begin shopping again
and checkout with a new cart with the first line item free again... that
means they could get 10 free items from 10 different checkouts.
Thanks for your time and thoughts!
P.S. Script is in Ruby. Also, Setting up a discount code won't work for my use case.
UPDATE
Thank you for your responses. I will be attempting these suggested updates this week and will post my results soon.
UPDATE 2
So the below suggestions and marked answer were all spot on except for one detail. The script editor keeps on running into some type of error even though the described syntax below is correct. Another stackoverflow answer suggested to use '&'.
So I ended up doing something like this:
customer = Input.cart.customer
if customer&.tags&.include?("gift_received")
...
end
This works for me. Thanks again for all your answers!
Any kind of solution could only work if Accounts are required
otherwise you can't track the history of orders.
There are two possible solutions
You create a flow that assigns a tag to a customer when they receive a gift. You check for the tag : Input.cart.customer.tags.include?('gift_received') and don't apply the discount.
If your case is just 'Gift on the first order' you can just check Input.cart.customer.orders_count > 0 and that's it.
Um. You can always just assign a little tag to the customer. For example, if they received this free item, give them a tag on their first order. Now, if they try and fool you nine more times, check for that tag. If they have it, remove the item from checkout. Boom. problem solved.
I have created a script in the Script Editor that makes your first line item in a cart free. I want this script to execute once per customer.
The best way is to flag customers using tags. You can use Shopify flows to add tags to orders containing free gifts to mark customers as the customers who received already free gifts. This will be better than checking Input.cart.customer.orders_count > 0 because it will give you more visibility in the orders & customers panel.
The approach mentioned by #Fabio Filippi is the best however it needs to be secured:
You create a flow that assigns a tag to a customer when they receive a gift. You check for the tag : Input.cart.customer.tags.include?('gift_received') and don't apply the discount.
Business use case:
Without adding this functionality to my script, a customer could checkout with 1 item free... but then they could begin shopping again and checkout with a new cart with the first line item free again... that means they could get 10 free items from 10 different checkouts.
Nothing prevents the user from creating a new account so you need to consider some verification logic that will be assigning the gift_received tag after the customer is validated.
If you want to avoid fraud I would consider using both (note that in this case we are checking if customer already bought something in the past) Input.cart.customer.orders_count > 1 and Input.cart.customer.tags.include?('gift_received') OR Input.cart.customer.tags.include?('gift_received') and Input.cart.customer.total_spent > Money.new(cents: 1000). This way you can have "eligible for gift" kind of logic. There are many ways to approach it.

Odoo shows only one type of taxes on out_refund tax lines, but should be more there

Client refunds (out_refund) show only one type of Tax in the tax list, even if there should be more than one. For example: I have this out refund lines: One S_IVA10B and other with S_IVA21B
You can see S_IVA21B and S_IVA10B, right? Well... if you go to Other information tab, you find only one tax line:
Any of you know why this is happening (only) on refunds? The out_invoice elements are correct.
It was a reported bug. Now it is solved in this commit: https://github.com/OCA/l10n-spain/commit/4ac7266648aab0fa469ae271a7541f6bec79f3fb
For unknown reason it haven't worked for me, but there is an official fix.

Calculate Length in Custom Attribute Magento

I'm killing myself trying to find the right solution for this problem. Here is my issue:
Selling Wires:
We will say a wire is $5.00
If you want 1 foot its $5.00
If you want 2 feet its $10.00
...
Each foot isn't a separate SKU. Its a recalculation of the total. Thats it. Really easy, but for some reason incredibly difficult in Magento.
How would I code this? Any ideas?
****UPDATE***
These are configurable products. Didn't think of that in the beginning.
One way to do this without adding additional attributes or logic is sell by the foot.
Have your SKU as wire-1-foot for example and use Magento's built-in tier pricing to customise your pricing for multiple quantities, aka multiple feet of wire.
You will probably also want to customise the block around the quantity field to make this a clearer for customers.
EDIT:
You could also consider grouped products as they behave slightly differently, e.g. http://www.webshopapps.com/blog/2010/11/tiered-pricing-on-configurable-products/

Magento - How to only allow one free product in a basket

The shop I'm working on sells desks. We also sell pens.
If you buy a Desk, I'd like to give you a pen for free. any further pens you add to your basket need to be paid for.
Currently, I have a Shopping Basket price rule that says the following:
CONDITIONS:
If an item is found in the cart with All of these conditions true:
Category is 3 (desk category)
Apply percent of product price discount: 100%
ACTIONS:
If All of these conditions are true:
SKU is one of pen1, pen2, pen3, etc...
I only ever want one free item in the basket though. I've tried just about every combination of conditions I can think of, but the simple fact is that Magento does not have an XOR or "run this action only once" condition.
I've even tried setting up three identical price rules, one for each pen, with "Stop further rules processing" set to "Yes". Each rule still processes in turn.
The closest I've come is adding a condition that says
If total quantity is 1 for a subselection of items in cart matching ANY of these conditions:
SKU is one of pen1, pen2, pen3
This condition allows one free pen in the basket, but removed the discount entirely if a second pen is added to the basket.
Can you improve on this rule?
It's not perfect, but I've got something that works for me.
I'm adding one rule per free pen. Each rule has an exclusion clause on it that says
If an item is NOT FOUND in the cart with ANY of these conditions true:
SKU is one of: pen1, pen2, pen3
It takes some playing with, and it's too complicated to run with any really complicated promotion, but it works for short, simple promotions. After much research I honestly think it's the best way of doing this in Magento.

How to stop magento from removing tiers that are more than or equal to the default price?

In magento i have my tiers set like so...
Regular Price: £8.99
Special Price: £3.75
Tiers
Buy 5-9 for £3.22 each
Buy 10-19 for £3.22 each
Buy 20-49 for £3.22 each
Buy 50-99 for £2.80 each
Buy 100 for £2.58 each
100+ Call For Pricing
With a minimum quantity set at 5 and also the regular and special price reflecting a qty > of 5.
The problem with the above being magento hides my first two tiers.
After debugging it i have found magento hides any tiers that are more than or equal to the default price / special price.
So i suppose my question is how do i stop magento from removing the tiers that are more than or equal to the price.
Thanks
Use $_tierPrices = $_product->getData('tier_price');
All of your tiers appear to be lower than the special price. Is that a typo?
Either way I think you need to look in the /app/code/core/Mage/Catalog/Model/Product/Type/Price.php file. Specifically in the getTierPrice() function.
That is pretty much where all the magic happens (and where your prices are being removed). You may have to make changes in 2 spots in this function as part of it is used for the product page and the other for the checkout process.

Resources