Does anyone know of what the "best" way to add shipping functionality to a current site? I've got the E-commerce module set up, working, etc... except I want to be able to add a shipping cost based on the country of the user. I've looked into ec_charge, but it does not look ready for prime time.
I've seen hook_checkout_form, hook_checkout_info, etc... but they look like they add bits to the form, and I'd really like to be able to make my shipping information be included with the checkout review table at the bottom of the page. I've played around so far with hook_form_alter and I can make the checkout part LOOK right, but implementing the complementing functionality in the background is beginning to look like it will end up being a bit difficult.
Any suggestions or resources one could point me at to help me in this minor quest?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Picture 3.png | 75.78 KB | gordon |
| #5 | Picture 5.png | 15.03 KB | gordon |
| #5 | Picture 6.png | 23.95 KB | gordon |
Comments
Comment #1
gordon commentedYes ec_charge is how you will do this, but I am still working on this. I am hoping to have it finished this weekend.
Comment #2
dwees commentedThanks for the quick response. I'll be more patient and wait for the next release. Also, thank you for incorporating my views stuff for the ec_product module into your previous release, it meant I was able to stop maintaining my own version! Very handy.
Dave
Comment #3
dwees commentedHi Gordon,
Did you get a chance to look at this?
Dave
Comment #4
gordon commentedSorry I actually forgot about this issue and only implemented ec_charge with some basic filters just to make sure that they were working, in the hopes of other people putting thought requests on the types of charges that they would like to be able to do so that I could test the API's and see how I did.
Implementing your feature request only took me 10 mins to add in the shippable filter so that a shippable charge would be included if there were shippable products.
ec_charge has been available since beta7 and I still need to add more componets to enable the building of more charges. I have added the shippable filter, and if you have any more charges that you would like to build please suggest them, or even implement more componets to allow yourself to implement them.
Basically to create the basic shipping charge you just need to create an additional charge with the following.
Add a shippable filter so that the charge will only be applied to shippable products. Next add a calculation and enter in the standard price that you want to charge.
Gordon.
Comment #5
gordon commentedAlso I have just adding a shippable variable which will return the value of all the shippable products. This means that you could create a charge which is for example 20% of the value of all shippable products.
I have attached images of the charge that I set up.
Comment #6
dwees commentedHrmm, the option to use some PHP code to set the shipping cost would be good. The shipping cost is dependent on the country in question. I can easily write some jQuery magic to make the external form look like it is updating itself, but it would be nice to then have the final shipping cost reflect the country in question.
This is great work, I think I can figure out how to get a flat shipping rate in pretty easily. It's just [Shippable] + 1.5 or whatever. I'll worry about the more complex shipping situation later.
Dave
Comment #7
dwees commentedSo just to let you know, I've successfully added shipping to my site! Very nice, relatively straight forward, especially with the screen-shots. Realized I didn't really want my [Shippable] + 1.50, just 1.50 by itself was fine for the "calculation".
Now to figure out how to get this to change depending on which country is chosen. Updating via jQuery is easy as I said, I'll take a look at how you define your variables, and do the calculation type stuff, and see if I can figure out some magic (ie hacking!) in there.
Dave
Comment #8
gordon commentedYes the calculation field can just have a number in it. it just means that it is not going to do any variable replacement in the and return the value that you enter.
This is something that needs to be done in that help description needs to be added to different areas to allow people to read my mind easier.
If you want to do something like this this would be a great help.
Comment #9
gordon commentedYes someone needs to add an address filter so that you can filter this charge based upon the either billing or shipping address, and any part of the address. This would include multiple combinations of fields, so you could do country and state in one filter.
if you take a look at ec_charge/module/node.inc you will see how to create a filter and you can create a hard coded version which only requires a couple of functions to create.
to hard code it would be something like
Now you can now add this as a filter to your transaction. There are also other functions that you can use for the settings form.
Comment #10
dwees commentedOkay so I've got the filter to appear, now I am working on the logic for doing the actual filtering. The code below informs ec_charge that I am creating a new filter, and the second function defines the settings form for the filter. This works fine.
The next step is to actually create a function to do the filtering, which is where I am stuck. I've tried defining the following function:
This is not being called when the checkout form is initially presented (should it be?). I do have another filter on the same charge which is being used no problem. Do filter's stack, or is it like a stack, and only the filter which applies get used?
Need to get the back-end working before I work on the jQuery magic.
Comment #11
gordon commentedYes I see the problem. It was that you missed the hook_filter_settings() which let ec_charge which parameters to save.
So you should have something like.
This will then save your list of countries to get it going.
Gordon.
Comment #12
gordon commentedAlso I found a problem with the paths getting stuffed up so I have fixed that.
Get the latest dev version.
Gordon.
Comment #13
dwees commentedActually I had the hook you suggested, and my filter was being saved fine. I'm not going to be looking at this for at least a couple of weeks though, some personal stuff has come up that I have to deal with.
Dave
Comment #14
gordon commentedOk, this was because of the file loading being broken. While I was working out your problem I discovered this and why it was failing.
This should be fixed now.
Comment #15
gordon commentedComment #17
marcin-mark commentedplease close thank you
Comment #18
gordon commented