It was hard to find a title for this topic… I hired someone to create a condition in the checkout, so I could show only a particular shipping method if at least one of the products in the cart was marked “yes” in a custom attribute (that has “no” as default):
if ($rate->getCode() == 'flatrate_flatrate')
The purpose of the condition is irrelevant on this topic. The point is that Magento has the following shipping methods:
For some reason I don’t understand this particular condition will only work when the rate code is written like ‘flatrate_flatrate’. I have seen such doubled IDs repeat themselves in several places in other files, so I guess it’s me who’s not savvy enough in Magento to get the grip on this one…
As long as I replace ‘flatrate_flatrate’ with:
…the condition above will work just fine. And that’s great.
BUT, the ID I need to replace ‘flatrate_flatrate’ with has two words, separated by a underscore, like so:
It is that way because this is a module that contains two shipping methods under the same shipping provider. The problem is that I can’t write it like that:
if ($rate->getCode() == 'modulename_modulemethodone_modulename_modulemethodone')
…because then the condition won’t work.
So I would like to know if anyone else has been through something similar and have a solution to this problem.
Any help is appreciated!
(PS: I only need to change this one line to get it to work, so please save your offer of a new module for another topic).