OK. Well I want a shipping module that:
1. has no 3rd party APIs
2. can be applied by product type
3. can do the + - % thing
4. allows me to have calculations done in order.
5. lets me use custom "display" descriptions
Some of the many and varied shipping calcs I'm thinking of:
1. fixed, standard shipping "surcharge"
2. configurable fee per product
3. standard fee per destination country
4. standard fee per weight
etc, etc
So an example. Calculate a destination fee, add a weight fee, and then add a surcharge which is % of the total cost. Because the % will be different depending on the order of calculation, we need to be able to specify an order of calculation. And also this break-down of shiping charges will show on the invoice.
This example might not sound believable to some, but the idea is that the real world throws up all manner of requirements and I want something flexible.
I've made good progress. I've got most of the admin done, like configuring which mods apply and letting them save their own settings (by product type) or settings on the actual node.
The actual checkout part is very rough, I'm starting to struggle here. I'm tricking the cart to skip shipbasic in the checkout because the user won't be choosing anything (I think). I've got a charge to display on the invoice, but not much more of the checkout stuff.
The module is attached. Love anyone to have a look, especially for advice about how to proceed in the cart. To set up I'd recommend installing at least 2 shipping modules like apparel and tangible. This will show you some of the dynamic admin pages.
To turn on methods for each product type,
admin -> settings -> content-types
Then everything else is found in
admin -> store -> settings -> shipbasic
Where there is a whole double-tab thing happening.
Note that there are hypothetical methods which don't really do anything. The only ones I've been adding specific properties to are:
- per_product (Set charges product by product)
- surcharge (Apply a general shipping surcharge)
I have it in mind to have a "partner" directory like shipcalc. So some of the functions I've started to name with the method as the first word, which should make a hook easy later. Any thoughts in this area are appreciatedt too.
Thanks
Simon
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | flexicharge2.zip | 46.52 KB | sime |
| #11 | flexicharge.zip | 46.53 KB | sime |
| shipbasic.module | 10.53 KB | sime |
Comments
Comment #1
Lupin3rd commentedThis module is what more people would!
In italy shipping works in this way:
1) a basic shipping cost for all product (10 € for: total weight < 5 kg)
2) if the customer buy more product and: 5 kg < total weight < 10 kg then i must add 5 €: 10+5 = 15€
3) 10 kg < total weight < 15 kg then i must add 10€: 10 + 10 = 20€
4) all shipping are 3/4 days but if a customer want receive products in one days then i must add 5 € to the total price
I think that a generic module like shipbasic can solve the problems for a lot of people.
PS: excuse for my bad english
Comment #2
simediscussed this with gordon. this will be more broadly named a "misc charge module", since it will allow admins to configure special charges and use custom descriptions in the invoice.
Comment #3
ardas commentedIn Ukraine shipping price is calculated on weight basis. As I know, there is no weight for tangible products which is strange because weight - is the most specific attribute of the tangible product.
The calculation formula is rather specific : a fixed price for first 10 kg. and then the price is growing depending on the weight. I think there is no need to implement it but the old approach from 4.6 (a table of ranges) is rather a good solution.
Comment #4
simeI intend to provide a weight calculation method. The way it works with tangible is that is responds to form_alter and adds the required field/fields into the product form.
Comment #5
ardas commented... this is only if you are using post service but if you want to organize your own shipping service the method may be any you like. My own opinion is the following:
1. Per product - USEFUL
2. Per price (table of ranges like in 4.6) - LESS USEFUL
3. Per weight (table of ranges like in 4.6) - VERY USEFUL
4. Per quantity (table of ranges like in 4.6) - ALMOST USELESS
5. Fixed rate (can be implemented as a ) - RATHER USEFULL (but can be implemented as a special case of methods 2,3,4)
6. Something like USPS - can't say because we don't practice it in Ukraine, but I'm sure they are USEFUL
7. Per product category (taxonomy) - MAY BE USEFUL
Comment #6
ardas commentedThis is for per product method ... and what about catching payment('adjust') hook to calculate price adjustment ?
Comment #7
simeThat is VERY USEFUL. :-) Thanks! It gives me an idea of priority.
FYI, the plan for UPS type modules (using 3rd party api) is that they will be written as "partner" modules of shipcalc.
Comment #8
sime"... and what about catching payment('adjust') hook to calculate price adjustment ?"
Can you please explain the charge(s) that you need in detail? I don't fully understand what you want from what I've read.
Comment #9
ardas commentedIn short, I need charges as it was made in 4.6
Comment #10
simeI have put a new module, sql, and a supporting .inc in the CVS.
http://cvs.drupal.org/viewcvs/drupal/contributions/modules/ecommerce/con...
To review.
1) install and activate flexicharge.
2) goto Administer > Store > Settings > Flexicharge
3) You can add as many charges as you like, each with a different name etc.
NB. There is only one TYPE of charge provided by example.inc. I have more types of charges that I haven't submitted to cvs yet. My aim is to get example.inc working properly first.
4) Once you have set up your charges. You can add a product and proceed through the checkout. See how nothing happens? That is because I am too stupid to get checkoutapi to work properly.
If you would like to help a stupid coder in need. Please follow the above and then look at example_general_flexicharge_checkoutapi(). If you can make that thing push the charge name and amount to the checkout review page then I'll be very grateful.
.s
Comment #11
simeSame instructions as previous post, but it should all work now.
Comment #12
simeOh, and the other modules in there need to replace what you already have (4.7)
Comment #13
Lupin3rd commentedi try to install your flexicharge module but i have an error in admin/store/settings/flexicharge when i try to add a new charge:
user warning: Column count doesn't match value count at row 1 query: INSERT INTO ec_flexicharge (provider, method, display, operator, rate, position, subtotal_before, subtotal_after, already_added, settings) VALUES ('example', 'general', 'Site-wide charge.', 1, 0, 0, '0') in /var/www/sites/luca/hardwareplus.it/subdomains/www/html/includes/database.mysql.inc on line 120.
Comment #14
simePlease hold out and I'll put some new code up soon. I am getting it reviewed to make sure this is what is appropriate for ecommerce.
(changing the status back to task as this is still a development task)
Comment #15
simeFixed bugs at #13
Comment #16
simeThe required changes to store.module are all in store_transaction_calc_gross:
1) For each misc, check if there is a callback to handle custom calculation. So rather than accept the default addition of $rate, modules can choose to interrogate the transaction and apply their own logic.
2) For each misc item, check for "already_added" and if so, don't add to the subtotal. This means that modules can specify an invoice item which is just a statement of an amount that was included in the original price.
Comment #17
simeThe required changes to cart.module are all in cart_checkoutapi. Nothing different in calculating the items. Until we get to the misc transactions...
I've restructured the way the lines are built so that flexicharge can push out subtotals where it likes. I have to track the line # so that doubled-up subtotals can be repressed. There is also a little bit that reflects the way store_transaction_calc_gross works, but this duplication is already there.
Comment #18
simefiles and patches are all in CVS now.
http://cvs.drupal.org/viewcvs/drupal/contributions/modules/ecommerce/con...
Comment #19
neclimdulI've been going over the code a lot. There are some decent sized changes and I can't find any glaring problems. The module works like a charm and with some spit and polish could be a very useful addition to the E-C line up.
I haven't run everything I can through it to make sure we're solid and so I'm not 100% on the cart/store changes. It looks very good and worked for me in my initial tests. Good stuff.
Comment #20
Lupin3rd commentedI try the module in my 4.7 ecommerce site. Works very fine! It's very usefull!
I have only errors with flexicharge.install. Then i use phpmyadmin to create table ec_flexicharge.
Have you yet wrote a provider that use weight to calculate charge?
Thanks a lot for this module.
Comment #21
simeI am very close to adding more charge types. Glad you like it so far.
Comment #22
simeCross-link to groups where you can add your ideas:
http://groups.drupal.org/node/837
Comment #23
chueewowee commentedHello fond you and tried it today. No problems (manual load of sql via phpmayadmin).
Works fine.Really looking forward to by weight too (zones in the future!).
1 thought: Why not have the + and % options combined as 5 + 10% for axample in one field. THis would allow for greater priced flexibility too, with items that weigh only a small amount (say 200g) and cost considerably more by % to post when ordered singly, than when ordered in batches of 5 or more according to the customers desire or need. An ilustration: protective creams for eczema baby going on a long trip abroad - i'll take twenty to the Swiss hilltop retreat.
As yuo can tell, I do not like overcharging customers for postage, and think it doesn't inspire trust or loyalty, and is dishonest or lazy or both.
Comment #24
JoshLangner commentedThis feature would be extremely handy to have. I have followed what little instruction / implication there is to install it on my setup, but it does not seem to add the values I select when I go to pay for products. I would like to see this module completed--it will be very useful when it does get done.
I would also like to see each fee listed on the "create product" page, where an administrator could select which fee to apply to which product.
Comment #25
JoshLangner commentedI can't get it to work right. I'm getting nothing but ZERO values in my checkout screen. Can somebody help me get this fixed?
Comment #26
simeHi Joshua L
Thanks for your ideas.
I advise against using this in production yet because it is basically at the proof-of-concept stage.
Comment #27
simeReview period is over.
Here is next step: http://drupal.org/node/83039