You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
I have changed my custom shipping method to a calculation based on the weight of the items ordered (unfortunately it's not a simple multiplier), but I want to be able to include the shipping cost in the mini cart so people don't have to go through to the checkout page to find out how much this will be.
I figure I need to alter ste_cart.pl because that's where the mini cart routine is, the problem is I'm not sure how to get the total item weights which in my ste_shipcus.txt routine is found in $item_total_weight
In "sub ste_cart_mini" (found in ste_cart.pl) there's this section:
$sql_statement = " SELECT cart_prodquantity,cart_amtprod,cart_amtrecur FROM cart ";
So can I just add in something like "cart_weight" or whatever the variable would be to get the total weight of items ordered?
Offline
Alternatively, would it be easier if I upgraded to 6.0?!
I hadn't before because I don't like upgrading when things are working ok ie if it ain't broke, don't fix it ;-) but maybe it's time for a change now...?
Offline
The total weight is something that would have to be calculated - it's not all as easy as just adding it into a SQL call. Even if you got the weight calculated in that routine, it doesn't execute the shipping script at that point, so you really have a lot of customization to get it to do what you want. ATS (aatechservices.com) has a shipping estimator module for 5.1, but you should definitely have a look at 6.0... would be a lot better to spend the money on the version that will be around a while rather than the one that's already past end of life.
Offline
I have the code for calculating the weight based shipping all worked out, it's already present in the checkout routine where I have the total weight of all the items easily available.
What I don't know is how to get the weight of each item in the cart whilst the customer is still shopping so I can add them up and calculate the shipping cost in the mini cart
Basically I can hack around bits of perl code to do simple stuff, but I don't know how to get it to read data from the product.csv file.
PS I appreciate what you're saying about 6.0, but 5.1 is still working fine for me at the moment and I wouldn't be able to upgrade until after the New Year anyway
PPS and even if I did upgrade, I doubt it would do what I want "straight out of the box" anyway which is why I'd like to get some help on this mod instead...
Offline
Well, I'll do what I can to point you in the right direction, but the specifics of a mod that large are definitely beyond the scope of current forum support for v5.1. Anyway, you'll be calculating the weight based on what's stored in the cart, not pulling it from the product table. The weight for each item is stored in the field cart_prodshipweight. You would need to get the weight for each line item, multiply by the quantity, add them up, and store the value in the variable to be accessed by the logic that determines the shipping cost. Of course, even that already assumes that all the products will go in one box to the same location... which you might have specified in the admin or not. So this mod will limit your cart to a pretty specific set of rules going forward and remove a lot of the versatility CCP ships with. It will also hard-code a lot of stuff that will all have to be changed if you move away from your current weight based custom shipping script. At any rate, that's the basic process and if you want to see how it is normally done, have a look at the subroutine ste_chkout_meth in ste_chkout.pl - that's where the shipping logic is normally accomplished.
Offline
Ok, thanks for this.
As I mentioned, I'm already doing all of this at the checkout stage, my shipping rules are specific (and simple), so that's not a problem.
I just want to let people know how much the shipping should be before they get to that point because it should hopefully stop people bailing out at the checkout if they suddenly decide they don't like the P&P charges (personally I find it very annoying when you've got to go to the checkout to find out how much someone is going to charge me for shipping, so I don't like doing it to others!)
Offline
Well good luck with it, and if you have any specific questions about problems you might encounter, let me know and I will try to help.
Offline