|
The reason that it doesn’t encompass all configurable products that you create in your products admin section is because this particular fix looks at the SKU of each item in your cart to determine how to do the tiered pricing.
When the cart calculates the price to display when you view your shopping cart, it takes a product and passes it through the php code (easily traced as it generally shows up as $product), and in the case of tiered pricing, the default Magento logic behaves as follows:
1) Check product quantity at this slot in the shopping cart.
2) If that quantity matches a tier, it gets applied.
The “fix” code that is referenced in the thread above enhances that process as follows:
1) Get product SKU (this is the SKU of the configurable product. **Note that Magento’s cart stores both the configurable product SKU and whatever simple product(s) are tied to that from the selections made from the configurable options as items are added by users of the store
2) Loop all items in the cart, get their quantity and store an array of quantities and SKU’s
3) Sum up all quantities in the cart where the configurable product’s SKU matches up - this gives the desired quantity to pass to the tiered pricing scheme because it says “ok I have Configurable product X which was added to the cart both in color red and color blue, giving me 2 unique records in my shopping cart, but the configurable product is the same at the end of the day, just differing simple products. Find me everything with the SKU for product X”. And then it uses that quantity to calculate the tiered price that is tied to the SKU of the configurable product.
That’s why if you have let’s say, Configurable Product X and Configurable Product Y and you want tiered pricing to manifest itself across both of those products it won’t work. The fix above would calculate all quantities for product X and do tiered pricing for it, then it would do the same for product Y. Independent summations of quantities due to the difference in SKU’s.
Now, my current client has a single product that they sell. It comes in several colors and sizes. The problem is they want to make it look like their site has more products than it really does, so they didn’t want a single configurable product with dropdown selections for Size and Color.
Instead, they wanted this one single product to be listed once for each available color, and then just have the Size option be configurable.
So if you were to navigate to the category for that product it would show 6 listings as separate configurable products:
Product - Red
Product - Black
Product - Blue
etc etc
Then if you clicked to view the detail of any of those configurable products, you could select the desired size from a dropdown.
This caused an immediate problem for me as a requirement because although the solution from the thread you linked above would solve the issues of when people purchase a product in more than 1 size i.e. configurable option, it would not cover this case where we technically have the same product spanned across configurable products.
They wanted tiered pricing to span all of these because at the end of the day, it’s all just the same product.
So for me I was able to tweak the php code to just look at all configurable products and ignore the SKU. Instead I could just look at the product type attribute in code and say “if this is configurable, add the quantity to my total” and then when I was done I’d just pass that quantity to the tiered pricing calculation.
However, my case is a simple one. If you want to have groupings of configurable products that can be tiered together, the change to my code is actually quite simple. All it would require is that you have a naming scheme for your configurable products to logically group them together. I would probably add a custom attribute to the attribute set of my configurable products (this would not be visible on the front-end).
Then in code as you’re getting a tiered price, you basically take the product’s attribute and look for any other configurable products that are in your current shopping cart that have the same attribute value.
Below is the code I tweaked for my purposes, but remember that this is dumbed down to encompass anything that’s configurable that’s in the shopping cart, because my client only has 1 product and will for quite some time, so for me, creating groupings based on custom attributes as I noted above is rather useless.
Not enough room in this post still for it so see my next post.
|