I'm not sure if this is a Commerce Flat Rate issue, Commerce Shipping 2.x issue, or Rules issue but I'll start here and give it a try. I followed Randy Fay's excellent tutorials on the Commerce Guys website to set up three flat rate shipping options (first class, priority, and express) and an upcharge to flat rate per item which is only supposed to add on to the first class option. Here's the scenario...

The client whose site I am working on has three domestic shipping options.
1) First Class ($4 for first item, +$1 for each additional item)
2) Priority $7
3) Express $25

Each of these three is set up as a Flat Rate Service and titled appropriately. For the First Class I set the base amount to $3 since the add was going to count the first item and add $1 which brings the amount for the first item to the $4 amount.

I followed the tutorial video to create a plus $1 and in the final action (Add an amount to the unit price) specified the First Class item as the Price Component Type. But, it appears that the shipping rate calculation rule I created is actually applying the add +$1 to all three Flat Rate Services (First Class, Priority, and Express) even though I specified in the Price Component Type to apply the calculation to the First Class one.

So, with two items in my cart, at checkout the shipping choices are showing as:

First Class $5 (correct)
Priority $9 (not correct - added $1 for each item to the base $7)
Express $27 (not correct - added $1 for each item to the base $25)

From the video tutorial on adding per-item shipping, the last step in setting up the rule is to affect the Product Component Type. I see all of my unique flat rate service options listed there and only selected the one I wanted the upcharge to apply to, however it appears to be increasing all three of the available flat rate service options presented to customers.

Any guidance extremely appreciated! I need to remove the extra amounts being added to the Priority and Express shipping options so we can move forward with the client's site.

Comments

see below...

Title:Add per item amount effects all shipping choicesAdd per item amount effects all shipping choices - Rule
StatusFileSize
new1.07 KB

Attached via text is the rule

If you can boil this down to a simpler situation (just one shipping rate?) and edit the issue summary (just edit the node) to make it as simple as you can, I'll try to take a look at it.

The debugging process means trying to simplify things as much as possible to make it so you understand exactly what's going on and so you can explain it concisely to others.

Thanks!

So here is the simplest explanation I can give and I'm changing this to a bug report based on my observation of how I believe the shipping calculation rule component type selector is supposed to work.

If you have more than one Flat Rate Service created and attempt to apply a shipping calculation rule to just one of those services, the Component Type selector (see image) when defining an action doesn't seem to work.

I'll include a series of screenshots so the whole thing is hopefully laid out.

As indicated above, when items are placed in the cart and during checkout, when choosing the shipping method, the first class method is correct, but the $1 per item additional cost from the rule, which is supposed to only be applied to the one Component Type (see screenshot six "As just my First Class Flat Rate item) is actually applied to all of the Flat Rate Services I have created (and that are listed in the Component Type pull down, though I only indicated the one when creating the rule).

I hope that specific and simple enough.

In response to Randy Fay's suggestion on IRC I tried to create a condition so that the rule only applies to my one flat rate service component type, but I don't really see how to specify it when adding a condition to the shipping calculation method.

Category:bug» support
Priority:Major» Normal

Still more than I can grok. This will have to be a support request until it's boiled down to a clear statement of something wrong with Commerce Flat Rate instead of something wrong with your application.

As far as I can tell, you don't yet have a condition that limits your rule to acting in the single situation you want it to act in. If you're not familiar with rules components (like subroutines) you may need one of them, with a condition and an action in it, to accomplish some things (especially when something inside a loop needs to have a condition attached to it.)

Thanks for the feedback, can you point me to the best resources to learn rules in your opinion?

Sorry, thought I already had. Itangalo's Learn the Rules Framework is the very best. Then the CommerceGuys channel on Vimeo, which you're already familiar with, provides lots of practical examples.

Status:Active» Fixed
StatusFileSize
new56.33 KB
new105.57 KB
new1.24 KB

OK, I took a careful look at your work, and it is in fact just a couple of conditions you need. In your shipping "calculation rule", you need conditions that tell it when to fire.

In my case, I made a flat rate type called "Charge Per Item" and added a calculation rule just as in the per-item shipping video, but that rule has to have a couple of conditions added to make sure that it only applies to the correct type of shipping.

FIrst, we do a Data Comparison to check to see if the line item is a shipping line item type.

Then we do a data comparison to make sure that the line item's shipping service is "Charge Per item"

After that, the calculation rule only applies to the service it's supposed to apply to.

When this works out for you, please return to all the places you've posted this and update the actual answer. Thanks!

Holy Crap! That works... but WOW... I feel like I'm playing twister to figure that out.

Thanks SO much for the guidance... no to dissect it and figure out exactly WHY it works. WOW!

(I can't repeat the words I was yelling at my computer as I tried adding single conditions to get at that... I got pieces of it but never put those two together)

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.