Closed (fixed)
Project:
Commerce Shipping Weight Tariff
Version:
7.x-1.0-beta1
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
5 Oct 2012 at 04:42 UTC
Updated:
22 Aug 2013 at 22:11 UTC
Jump to comment: Most recent file
Comments
Comment #1
joachim commentedSee the README.
There's no UI to add services, as I'm on a tight deadline. Also, I feel this might be better done centrally by #1803244: add a common system for admin creation of shipping services.
For now, you can add them in a custom module using hook_commerce_shipping_service_info()
Comment #2
rojesaga commentedI understand the situation, I appreciate your time, and I'll try the solution you propose.
Comment #3
markalosey commentedWith a module name: ahf_shipping, the following code creates the service. (Insert naming as desired)
Caveat: as mentioned you have to change in the commerce_shipping_weight_tariff module the constant set up for the weight field on your product before any calculations will take place. After that, it works like a dream.
Comment #4
joachim commentedI'll add an example like that to the README.
Comment #5
Tamanda commentedThanks for this example module for a shipping service. I've made this module and successfully installed. I have also installed the commerce shipping weight tariff module. I'm using thee latest drupal commerce kickstart, commerce shipping, commerce phyiscal and commerce physical product. The shipping service still doesn't show because I haven't set the weights. That's the problem. However, could you please tell me where in the commerce_shipping_weight_tariff module code am I to set the the weight field on my products. I understand that I am supposed to hard-code them into the module. I'm guessing it would be an array. I've been looking at the code in commerce_shipping_weight_tariff.module and can't find the answer. Please may you help me?
Comment #6
joachim commented> However, could you please tell me where in the commerce_shipping_weight_tariff module code am I to set the the weight field on my products. I understand that I am supposed to hard-code them into the module
It's right at the top of the module code, clearly marked:
Comment #7
Tamanda commentedThanks for that very quick response. I should have stated that I'm still learning php and so not very good yet, sorry about that. So I have found that the machine readable name of my physical weight field is field_weight . I have since changed the code:
to
I've saved all files, manually ran cron, ran update.php and the shipping service is still not showing. I have tried various other things to no avail. I honestly don't know where I screwed up. Where the service was supposed to be listed it just shows "There are no services defined for the Weight tariff shipping shipping method." (at the following path mysite/admin/commerce/config/shipping/services/weight-tariff-shipping) . The service doesn't show even though that custom module was made.
I want to use this module purely for the ability to re-calculate shipping rates based on total order weight within weight brackets and not specific weight values e.g.
order weight: > than 0kg but equal to or less than 1kg = $10 dollars shipping
order weight: > than 1kg but equal to or less than 2kg = $20 dollars shipping
order weight: > than 2kg but equal to or less than 3kg = $30 dollars shipping
I know this module can help me achieve this. I tried rfay's sandbox module here and I've also watched the video tut. It worked fine except it would calculate shipping not in tariffs but based on the per kg shipping rate e.g. like above, I would want an order of 1.5kg to attract a shipping charge of $20 but with this module it would set it to a charge of $15. So, when I discovered this one, I knew this module would be ideal in this case.
Sorry for being long-winded, I just want to make sure I've supplied enough info for people to point me in the right direction.
Comment #8
joachim commentedHave you defined services?
Comment #9
Tamanda commentedI don't know. Where do I do that? The thing is, I assumed that commerce shipping module, my custom module from comment #3 and the Commerce Shipping Weight Tariff module would pass the necessary values on. I have attached the shipping service module that I threw together from comment #3 and installed (and enabled). I thought that this shipping service was defined in this line. This isn't it?:
from the following code ( didn't change the names from markalosey's post) :
The module I'm using from the above code is attached.
Comment #10
Tamanda commentedThanks for your willingness to help me.
I tried this and also this ...and various other things.
Finally, managed to find an alternative means to accomplish the same. I am using the the sandbox module attached to this comment here (#15) . now that I've gotten more comfortable with Rules. As the developer of it states, it's a little module that generates the Total Order Weight option in Rules which you can use for the Rule conditions of your flat rate services.
Therefore, I installed the module, enabled it, and created flat rate services for the different bands (or ranges for different shipping tariffs). After that, I configured each service's component by editing the Conditions, using the Total Order weight option now available.
This video also helped me to understand using Rules better and how to accomplish what I wanted (though using a different example).
(Only stating the above for someone with my level of competence on this in-case they are struggling.)
Even-though I'm not using your module, Joachim, thank you for your support and hardwork. I love drupal. :)
Comment #11
scripter81 commentedHello,
I'm asking for some help generating the service.
I red the topic over and over, but I cant find a way to create a service, now I'll explain what I've done:
The point is that there are no service in the service list. It's not clear to me how the module create the service, do I need to invoke it somehow?
I'm not really used to module creation, so I really don't know how it works.
Can you please explain me a little more what I'm supposed to do after I installed the module to create the service?
Thank you in advance
Comment #12
joachim commentedIt's been over 6 months since I was last using this module or looking at the code, and I'm afraid I don't remember at all. Try reading the comments in the code -- I usually am fairly diligent about adding comments that explain how things are working.
Sorry I can't be of any more help. This module needs a new maintainer -- or I need to be on a Commerce project again so I can pick it up and polish the rough edges.
Comment #13
scripter81 commentedHi Joachim, I watched your code, and it is pretty clear, the point is that I follow the instruction but I'm just missing something. In the code you say to create a custom module implementing the hook_commerce_shipping_service_info() function.
I've done that but, probably cause I'm not really used to module creation, I don't know what to do now. The module is done, it's activated but the service is missing yet.
Well thank you anyway, I'll search some other solution, cause I'm stuck on this one.
Comment #14
joachim commentedI's possible you also need hook_commerce_shipping_method_collect_rates().
Failing that, best thing it to step through the code and figure out how the data is being built up.
Comment #15
scripter81 commentedI manage to create the service. I'm not sure if it's the right way, but I edited the commerce_shipping_weight_tariff.commerce.inc file in your module
Instead of creating a brand new module I insert the code of the comment #3 in the function commerce_shipping_weight_tariff_commerce_shipping_service_info() and the service now appear in the list.
Now I try to configure it, and I'll let you know how it goes.
Thank you for your time.
EDIT:
I create the Price Matrix, and it works. I hope it helps somebody else :)
PS let me know if you think I made the wrong thing ;)
Comment #16
joancatala commented#3 #15 it helped me a lot your comments, and finally I did it well for my new project.
I wrote the trick on my personal web page (in spanish language):
http://jcatala.net/categoria-drupal-i-php/distinto-precio-en-el-shipping...
I hope this helps to somebody else. Thanks for your help.
Comment #17
oldenboom commentedI've succeeded as well by reading the comments on this page. However, it took a bit more reading as I didn't have any module-creation experience yet. From the comments I understood I'm not alone in that situation. Someone here suggested to modify the commerce_shipping_weight_tariff module code itself but I wouldn't recommend this: at the next update of the module one might loose his modifications. The creation of a new module hooking into the commerce_shipping_weight_tariff module is the way to go just like Joachim explained.
So, I decided to try to clearly explain each and every step I had to make to get this going.
I wanted to add a postnl shipment method and have chosen postnl to become the new module name - just replace it everywhere with the modulename of your choice.
Create the directory sites/all/modules/postnl
Create the file sites/all/modules/postnl/postnl.info - this file defines the interface to and dependencies with Drupal. The contents of this flie should be something like:
Then create the file sites/all/modules/postnl/postnl.module - this file allows us to hook into the Drupal functionality. The contents of this file, derived from #3 above, should be something like:
Note: omit the closing ?> as instructed in the coding guidelines at http://drupal.org/node/318.
Now enable your postnl module. Yes, you've created a Drupal module now. Not too difficult at all.
With your browser visit /admin/commerce/config/shipping and choose weight tariff shipping if you have, like me, for instance flat rate added as well. The postnl shipping service should show now.
Now create the products for the different weights using /admin/commerce/products/add. Choose 'create shipping tariff' and ensure shipping service is set to 'PostNL shipping'. The other fields are easy enough to grasp. Continue creating additional products for each maximum weight until you've got everything covered.
Comment #18
Daemon_Byte commentedI decided to make it even easier for you. The latest development code (03.08.2013) now contains a UI to allow you to edit, add and delete as many shipping services as you want for weight tariffs.
Comment #19
charleed commented#18 This is brill!
I found that when i added a shipping service and used feeds i had to name my shipping service - in the original csv - with all lowercase and no spaces otherwise it would say Notice:Undefined Index... (just in case anyone had the same issue as me :) Thanks (first post!)