Help - Search - Members - Calendar
Full Version: Multi_Vendor_Shipping new thread
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Contributions / Add-Ons > Shipping Modules
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73
blucollarguy
I am planning on integrating MultiVendorShip in Vendors_Auto_Email and am open for input. Has any one gotten the original Multi_Vendor_Shipping mod to work? I have seen a few requests for help, but no replies. I have just installed it and am going through the errors to see if I can get it working. All input and suggestions are welcome and needed, this will be very valuable to me as well as many other folks I think. What do you think? mellow.gif

Code in development is located here
mugitty
Craig;

I am thrilled that someone is looking at this again. I've been trying to find the time (and the code-writing ability, which is even more difficult) to do something with this.

As I understand it, the original contribution was independant from any other shipping modules and allowed only for a single shipping method per product (and only one option within the selected method). If something could be written that would present all installed shipping modules on the item addition page in admin and allow for selection of multiple methods for any given item, that would be a HUGE step in the right direction.

With that ability on the item page, one could add as many shipping modules as needed to accomodate their various needs for all products and then select the appropriate module(s) when adding products.

Examples:

Item A: Ships from your location and can be shipped via UPS or USPS using any available service offered by those carrriers to any destination
Solution: Select the standard UPS and USPS modules.

Item B: Ships from your supplier's location and only via UPS
Solution: Select your customized UPS module which has your supplier's ZIP code set as the origin.

Item C: Ships via truck at a flat rate only to the continental US, all other destinations require a specific quote
Solution: Select your customized flat rate module which produces the flat rate when appropriate or a "Contact us for shipping quote" message if the delivery address is outside continental US

Item D: Ships from your location but is an oversized package
Solution: Select your UPSXML with dimensional support module which will yield appropriate rates for the oversized package.
(I still have hopes of eventually doing something with the USPS module that would accomodate oversized packages - this will have to be done within osC though, since the USPS API does not support a direct submission of dimensions. I currently have tables for all countries which show the various maximum weights and sizes allowed by USPS and, with a little guidance, could probably help to write this)

Then, of course, if the customer's shopping cart has a product mix in it that dictates more than one shipping method must be used, a way to effectively present the shipping to them will have to be solved.
blucollarguy
I'm gonna give it a shot. I am no coding genius but I may be able to figure it out with a little help here and there. the features you write about are exactly the functionality I am hoping to accomplish. The way I hope to get this done is to tie each product to a "Vendor". Each Vendor would have specific selectable shipping methods available, and at checkout, each would reconcile to one clean presentation to the customer. So, one would set the methods available from the "Vendors" page which would include package origin, and then simply select a vendor from a dropdown in the prod add page. I am using this already in my contrib "Vendors_Auto_Email" and hope to add the shipping functionality. You can see what you think of the layout i "Vendors_Auto_Email" by downloading it from the link in my sig. If you don't want to send emails just leave you vendors set to "0" which is the default setting for "no email". If you there is anything else you can help with let me know, and keep an eye out for my screams for help. Thanks, Craig. smile.gif
spoot
I believe I found a conflict with multi vendor shipping & First Item $X, Additional Items $Y Shipping. I don't think it's so much an issue with multi vendor shipping though - I haven't really delved into it, but I think the first item $x module has to be updated to say "only items with this shipping_type should be included in the count."
blucollarguy
Thanks Michael, I will add this to my notes and keep an eye out for this type of conflict. Craig.
clewist1
I'm not sure which Multi Vendor Shipping contrib you were talking about originally (there are two, look here).

Anyway, I've been toying around with the Enhanced Multi-Vendor Shipping (EMVS) Contrib this week, and have gotten it to work, although not perfectly.

Concerning the post by Spoot (two posts up), there is an issue like this in EMVS. EMVS allows for you to specifiy an "Indv. Shipping Price" and an "Each Additional Price" for every item. However, these prices are only used in the shipping calculation if the Products Shipping Method for that product is set to "Individual Shipping".

However, I also found another error with this today. If you have two items in your shopping cart, and one of them ships via Individual Shipping (and the other uses, say, FedEx), then the calculated shipping will end up being the FedEx price for the one item, plus the Individual Shipping price for both of the items. This is due to how the Individual Shipping Price is calculated.

Anyway, I would go into more detail, but don't want to waste the time because I'm not sure if others here are even using EMVS. I also don't really know much about the differences between the two (for all I know they might be the same thing).
blucollarguy
Hi Craig, yes EMVS was a MultiVendor mod, or update. I have been going through the code to see how these folks went about things in these versions. My plan is to get as close as possible to the basic outline that Stuart wrote about in a previous post here. I appreciate a great deal your input, especially with known bugs or scripts errors since I am hacking this code to use for my version. I am going to link to "shipping origin" through each product being tied to a vendor. I hope to be able to create a script that will enabel us to select which INSTALLED shipping modules can be used for each vendor. If you have any suggestions or comments on how we can get this working I am open for all. I will be integrating this into "Vendors_Auto_Email" since I have already created the ability to link each product to a vendor in that code. If you want to see how I have done things there you can install it without using the email function since you can enter Vendors and specify NOT to send order emails. thanks for the input so far, Craig. smile.gif

btw-Cool name you got there!
blucollarguy
A question for those following this dream of a contribution. Should we try to create the possibility of the option of showing the cusotmer separated shipping quotes?
Example: "Your order contains items that may ship from separate locations, the shipping options for these items are:
Item #1
Item #2 UPS gnd $23.32
UPS 3dc $29.50
UPS 2ds $34.25 please select one
----------------------------------------------------------
Item #3 UPS gnd $15.32
UPS 3dc $19.50
UPS 2ds $24.25
FEDEX $24.75
USPS $19.00 please select one
----------------------------------------------------------
total shipping - $(from adding selected for items 1 and 2 plus selected for item 3).

This would tell the customer that items #1 and #2 will ship from the same location and that item #3 would ship from another location and give them the choices for shipping that have been enabled for the vendor tied to the given products in the order. (obviously, #1 and #2 are from the same vendor, and #3 is from another). This would eliminate the conflict that would occur if products from vendors with different shippers enabled were in the order. How else could we sort which shippers to obtain a quote from? The more thoughts on this the better. Please let me have your opinions. Keep in mind that I can not guarrantee that I will be able to accomplish all of this, but I have to try. Craig.
mugitty
Craig;

I don't see any way around presenting separate shipments to the customer, else they won't be able to select their shipping preference for those shipments that offer them an option. It's probably also advisable to show them which items are in which shipment.

One might present it as:
QUOTE
The items in your order ship either from different locations or via different methods. Please select (if options are available) your preferred shipping method for each shipment.

Shipment 1:
Product: (model) Description, (model) Description
Shipping Options: Method 1 - Option 1  Price  (select box)
                                              Option 2  Price  (select box)
                                              Option 3  Price  (select box)
                              Method 2 - Option 1  Price  (select box)
                                              Option 2  Price  (select box)

Shipment 2:
Product: (model) Description
Shipping Options: Method 1 - Option 1  Price  (select box)

Total Shipping for selected methods:  Total Price

All of this could appear only on the shipping page and then just a combined shipping total on the order confirmation page (Of course, the admin view of the order would need to show the shipping method details and which items were split into each shipment, so maybe showing the items per shipment on the confirmation page is advisable. I suspect that it is also a good idea for the customer to be able to see the shipping details on any page shipping is presented). An intelligent decision by the cart is also required so that if an order all goes in one shipment, the available options are shown just as they are now, without any of the above multiple shipment related 'stuff'.

The total shipping entry would need to update either upon selection of the various options or with an 'update' link.
blucollarguy
I agree Stuart, and that will be the direction in which I will work. It is evolving slowly. There are so many possible ways of doing this that I am trying to let this evolve rather than be too stringent with a plan, but I think I will end up without using an additional shipping module to handle this. I believe I can use all installed shipping modules with the "origin zipcode" being pulled from the Vendors table along with any additional fees or charges one might want to add for any given Vendor. How to present all of this to the customer and store the info in the orders table will be difficult. I am hoping to have some results this weekend. (some basic functionality). LOL, I may be able to do all this, then again, I may fail completely and have to start over LOLOLOLLOLOLOLOLOL!!!! biggrin.gif
mugitty
QUOTE (blucollarguy @ Jul 16 2004, 03:04 PM)
I believe I can use all installed shipping modules with the "origin zipcode" being pulled from the Vendors table along with any additional fees or charges one might want to add for any given Vendor.

Craig;

That's an excellent thought that never occurred to me. If you have a vendors table in which you can specify additional fees or charges, it could be used for any number of purposes, such as:

Separating Handling fees from shipping charges
Accomodating additional charge for oversized packages if you are using shipping methods that don't deal with dimensions.

Since the "Vendors" don't have to necessarily be actual different vendors, this feature would give you a lot of flexibility for dealing with odd charges that you don't want to apply to an entire shipping module or show as part of your product price!

You are indeed tackling a large, complex issue here, but one that will greatly enhance the shipping capabilities of osC, so any help I can give is there (but my php coding abailities are limited to finding something already written that does what I want it to and then copying it into the specific format that I'm looking to achieve or, on a good day, actually writing a couple of lines from scratch). ohmy.gif
blucollarguy
Thanks for the support Stuart, with some work and some help I think I can get this done. I had not thought about using the vendor table without actually using different vendors, but your right, one could create vendors for product specific purposes rather than just Vendor specific products. Quite a thought! And even if I have to use a separate shipping module the way the original MVS was using one, I am still going for this same type of functionality, so we will see!
zebrax
I am very interested in something like this. I have played with MVS in the past but it didn't work the way I needed it to. Something like this is on my todo list, so if you need any help let me know.
blucollarguy
Great Dax, I am always in need of help! While I am here I will post a small update on progress. I am slowly working the needed methodology. First, we need to build the "product" list that is sent to each shipping module a little differently thatn is currently implemented. It needs to be a "Vendors Products List" so that we can quote by Vendor not by product alone. I worked out the basic code last night to create the first leg of this list. I was very pleased I received no errors from this array. From here I will need to create a new variable, multiple zipcodes to then pass to thet shipping modules along with any added fees. The fees will not be very difficult I think since they can be added separately from the shipping modules themselves. I am not sure still about how much code work will be needed in each module if any. I hope to be able to fool each module so as to avoid the need to hack the code in each individual module.
So any way, this was a good start for me since until last night I was still not entirely sure of quite how to process all the needed vendor info. It is becoming clearer though. Any thoughts? Anyone? I will hopefully have time this weekend to get much done. Craig biggrin.gif)
blucollarguy
Ok folks, I'm getting some strange results. I have tracked down where we need to add or modify the info we need for the "Vendor Shipping". In catalog/includes/classes/shopping_cart.php, all the products info is collected and sorted such to be passed to the shipping modules, then the "class" shipping.php collects and sorts the shipping modules to be used for the quotes. So, these 2 files will need to be modified. Or I can try to create a new "class" to handle the functions we need. The code would be much cleaner if I can modify rather than create. That in mind, my plan is to create a "vendor" list rather than just a "product" list. Then pass the needed info on. The problem I am having is that the tables don't seem to be linking properly with the code I am used to using, the following code structure works in several other mods I have done:
// products price <-----mlti_vendor v.products_ship_method,
$product_query = tep_db_query("select v.vendors_id, v.vendors_name, v.vendors_zipcode, v.handling_charge, p.products_id, p.products_price, p.products_tax_class_id, p.products_weight from products p, vendors v where v.vendors_id=p.vendors_id and p.products_id = '" . (int)$products_id . "'");

However, this is returning this message:
1054 - Unknown column 'v.handling_charge' in 'field list'

select v.vendors_id, v.vendors_name, v.vendors_zipcode, v.handling_charge, p.products_id, p.products_price, p.products_tax_class_id, p.products_weight from products p, vendors v where v.vendors_id=p.vendors_id and p.products_id = '46'

I know that "handling_charge" exists in the "Vendors" table along with the ID, zipcode, name and many others. So, if it can find these other fields, which apparrently it can since the error starts after processing the others, why is it having trouble with "handling_charge" and nothing else? I don't get it. Any ideas anyone?
blucollarguy
My idiocy can be quite overwhelming at times. Found my error, a space included at the end of the name in the db. DUH! Sometimes you just have to ingnore me.
blucollarguy
Man this is a pain. Getting the modules to switch the zipcode that is pulled from the DB entry from the store data has been difficult. I am going to take a right turn and try to procede by rewriting the MLTI Vendor Ship contrib to call to "Vendors" table and use the vendors zipcode. I have already tied each product to a vendor through VA_Email, and have altered that table to include the shipping options, S/H, and any other fees one might want. I need to decide if I should enable each shipping method through the Vendors script or the MVS script, this would include which modules to use for each Vendor and set up all options, ship/handling or whatever, per Vendor. Any thoughts anyone? Craig smile.gif
mugitty
Just a bit of free-form thinking here... maybe it will help:

Product entry page in admin has added fields for
1) Dimensions It may not seem critical to some, but if you ship larger or heavier products, this can be very helpful down the road and with the existing UPSXML and Canada Post mods which I believe both support dimensions. Additionally, the UPSXML has a packaging add-on that would probably be useful to split off so that it could work with other shipping methods as well.
2) Vendor The vendor mod contains the setup page where you are able to specify all of the particulars on a per-vendor basis: Shipping method(s) {important here to allow multiple shipping methods to be selected}, handling fees, origin zipcode, specification of address to send extra email to, etc.

All shipping modules remain basically unchanged and are just called to be either enabled or disabled, based on the vendor assigned to a given product. Obviously, modules that rely on an origin zipcode will either have to be duplicated and given different names in the shipping module folder or amended to send the appropriate zipcode via the API for a quote. Multiple products from the same "vendor" are determined first, so that total shipping weight, size and cost can then be determined.

The vendor mod itself can either be actual different vendors from which you source your products or it can be different combinations of valid shipping methods, or a combination of both. You are able to dictate, on a per-product basis by selecting the vendor, which shipping methods are available for the product. (Similar to the existing shipping per product mod, but with much more flexibility)

The presentation of shipping methods to the customer is such that they see a separate group of shipping options for each "vendor" that is involved in the total makeup of their order.

Sorry if this repeats things from earlier posts - I didn't take the time to review before I wrote this.
blucollarguy
No need to be sorry, at this point I need input just to make sure I don't lose touch with the possibilities and necessities. You are right on the point though. Each Vendor is individually created and therefor we should be able to define ALL shipping info for each. Which modules to use, shipping charges of any type, max-dimensions, tare weight, whatever! Sounds great huh!? I am trying. Trick that I have had trouble with is that I did not want to re-write each module, but since each use slightly different code to call for the "origin" zipcode, I am beginning to think that it may be necessary. Or, I could go back to the original MltiShip module which was a standalone module that used the other mods code and settings, but each of the others were disabled so that they did not call for quotes themselves. I will take a look at the "per prod" contrib and see if it can at least offer some suggestions by it's functionality. Have you installed VA_Eamil? I am wondering because my intention is to use the "Vendors" table and products link from this script, integrate the shipping info into the Vendors_Auto_Email mod I have already done. I still need to clean up the "Add/Edit Vendor" page, but it functions very well. I have been also working on including the vendor's price and vendor sort to some reports I am using, been very handy to see a complete sales report. Any way if you have any more thoughts on how best to get this done please tell me, If you would rather collaborate through email PM me and I will get back to you. smile.gif
joeyjgarcia
Hey Guys:

I like where you are going, if I can be of any help I'll be happy to help out. I am very comfirtable coding in PHP.

Here are my thoughts after reading this whole thread.

1) I think it was a good idea to start talking about how it will be used (called a "Use Case") rather than what features you need to use. The Use Case will flush out the needed features (AKA requirements).

2) I think putting up your vision of what it will look like was another good idea. I am a software developer and I always start with a mockup and bounce it off the stake holders.

3) I don't use any other contributions in this context, but I want to start selling product from two vendors from two locations and I know the shipping will kill me if I don't show it to the customer and let them choose for themselves while making them aware that this is because the products they chose come from multiple vendors. I like your ascii mockup.

4) I like your idea of creating a vendor (or a vendor location) table and I would think that you want to add manufacturers to a vendor location instead of adding a vendor to each product. So if I have a bunch of products made by sony, rca and jvc but they all come from the same vendor (say Vendor Location A) then in an Admin page I would set the manufacturer, sony, rca and jvc to Vendor Location A and then I wouldn't have to touch the Product Page at all, assuming my products already have the manufacturer set. In the check out page I would query using the product_ids to find out which manufacturers are involved in the cart contents and how many vendor locations the whole orders has. Let's just say it has 2. Then I would get the zip codes for each of those 2 vendor locations and then I would separate the order by these 2 locations and add the weight leaving these 2 locations, then loop twice on the "Choose Shipping" page in the Checkout process, each time it would get a quote for the separated weight and the Vendor's Location as the origin and the customer's shipping address (much like it does now. You could also indicate this is going to happen in the shopping cart by displaying that there are multiple vendor locations involved in the contents of your cart.

Am I oversimplifying it?

I'll support you any way I can!!

Joey
mugitty
Joey;

First, let me say that I am excited to have someone else express an interest in getting this developed. As I am not a great amount of use when it comes to writing code, I was starting to worry that Craig might get that entire chore dumped solely in his lap!

I wouldn't necessarily say that you are oversimplifying the desired scenario - the simpler, the better - as long as the desired results and/or capabilities are achieved.

I would offer an observation that might have a bearing on some people's use of what is being proposed:

If one has a given manufacturer that can be sourced from more than one vendor and that choice is made based on who has a given product available on any given day, then to utilize a manufacturer assignment to vendor format would create some problems. I don't think it's a bad idea, just that there are some situations in which it would not work. I personally don't see any problem with adding one more field to the Product Page (which won't be there at all for people who have no need for the type of modification we are discussing here, because they will not have installed it). Could not a manufacturer be synonymous with a vendor if one always ships all of that manufacturer's products from the same vendor?

I guess from a selfish standpoint I should point out that my primary desire in the development of this idea is to be able to dictate, on a per item basis, which shipping options will be allowed to be shown to the customer. This stems from having products from the same manufacturer, some of which can ship "any ol' way" and others which can only be shipped by truck freight, due to their weight and/or size. The idea of having one additional field on the product page where I could make that determination seemed like just the ticket to solve that problem.

Again, I'm thrilled to have another brain working on this, let's keep the discussion lively and moving forward! wink.gif
blucollarguy
Awesome Joey, I will need the help working out the code for this as I have already started and stopped many different attempts from different directions. I think the problem with adding Vendors to each product from a separate page in the admin would be time involved during new product additions. The way I am currently tieing prods to Vendors (and therefore each location, would happen in prod add screen the same way you tie a manufacturer, from a dropdown) and this seems a logical spot since you will have the option with every new prod every time you add or edit a prod. The rest of what you have written is exactly what we want to accomplish. I have already created a Vendors table and the ability to tie each prod to a vendor in my contrib Vendors_Auto_Email. My plan has been to simply add the shipping info to that table and everything will happen at once. One does not have to send the Vendor any Email to use the V_A_Email contrib so it seems an easy step to use this as the starting point where to store the ship info. If you can would like to see how I am doing this you can download V_A_Email from the link in my signature. I would appreciate your coding help a great deal so let me know what you think. A lot of people can get a lot of value from this functionality I think, I know I will and many others who have already contacted me. If you have the time I can certainly use some guidance with this code. Replacing the zipcode from the STORE with the zipcodez from the Vendors has been difficult since each shop module is a little different and I fear a rewrite of each module would be needed. What do you think? Thanks again for the input, Joey. Craig smile.gif
blucollarguy
Another thought. We would probably need an additional "fee" field in the prod screen for misc fees. For instance: Vendor's Prod A requires custom packaging, Vendor charges $10.00 for this packaging, and all shipping options are the same as all other prods from this Vendor. This would need to be implemented per prod not per Vendor. I have not looked at the "Per Prod Ship" cnotrib but I would assume that this is done in some way in that contrib. This does not seem overly difficult, but would need to be included in the shipping calls in each quote. Thoughts?
blucollarguy
Manufacturer thoughts. We might be able to tie manufacturers to vendors as an "option". This had not occured to me before, but it could be very useful to be able to not only get the quote from whichever Vendor has the given manufacturers prod available but also to sort the order in kind. Availability checks would be needed, I think. I think this would need to be much deeper than the shipping mod itself, though. If all of manufacturer B's prods only come from Vendor C, this would be, in theory, not that difficult to a achieve, I think. While working on VAEmail I was a bit surprised as to how simple it was to tie each prod to a Vendor. Then calling that information for use in the email was what gave me the most difficulty. And, here again, this is what is causing my frustration with my early attempts with this MVS mod. Adding the info to be available is relatively easy, getting and using properly is the tricky part. Just thoughts bouncing around thoughts in an otherwise empty mind.
zebrax
Each shipping module is going to need some code change since most use a constant to get the origin zip. in the modules I have looked at, it should only be 2 line change.

CODE
$country_name = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true);
     $this->_Origin(SHIPPING_ORIGIN_ZIP, $country_name['countries_iso_code_2']);


changed to
CODE
global $origininfo;
$country_name = tep_get_countries($origininfo['country'], true);
     $this->_Origin($origininfo['zipcode'], $country_name['countries_iso_code_2']);


the key here is rewriting the shipping class to change the value of $origininfo before calling each need module.

the shipping class uses the cart class to get the products and coresponding vendors, it sorts the items by vendor, adds up the weights and calls the valid shipping modules for each vendor. it then returns the totals of all the different items and methods.

Now if I just had some time I would code it....
joeyjgarcia
I understand your agenda, I also have my own and I think that is reasonable. We want to have a tool that will work for our needs, especially if we are going to invest our time and labor.

I see this as a multi-part approach.

Part I

For the categories.php page:
If you have some products that ship on a truck while other products through the mail, but both are from the same vendor then a vendor list will not suffice. We would need something more specific. I don't think this is inline with my original idea, but since we are creating this from scratch it probably wouldn't be too hard to add in. I think that we can't focus on vendors then and have to focus on "Shipping Type" or "Shipper" or whatever. This table would need a Vendor Name, Zipcode, and handling fees (that could be used to pad the shipping cost when necessary), possibly a couple more shipping metadata for boxes, etc but I think the handling fees can take care of this more easily. So the Add/Edit Product page would have a "Shipping Type" drop-down list. Keep in mind that you could have different Shipping Types from the same vendor. Would this work for you?

For the Checkout_shipping.php(assuming this is the right name) page:
You would need a query that can start with a set of product_ids and determine how many shipping types are needed and that number will be the number of time you loop (using a for loop). This should look something like this select distinct count(shippers_id) from products p where products_id in (23, 45, 89, 13, 25, 68). This is just psuedo code; I can help with this query.

You will need another query to get the shipping type information (zipcode, handling fees, or a specific shipper for special shipping methods like trucking (I am clueless here)) to get the quote from the shipping web sites. Again, much like it does now.

It would be nice to have the product model number displayed in the same area for each shipping type. For example, if a customer is wondering why his/her shipping cost is so much they will be able to see that product 123, 456, and 789 are going to be shippied via Shipper 1 and products abc, xyz are going to be shipping from Shipper 2 and the capability to remove these items from the cart with a single click. This give the customer an oppotunity to remove items that are driving up their shipping cost or at least make them aware of what it going on.

You'll need to add the shipping sub-totals of all the shippers then add that to the main Shipping variable and call that "Shipping Total" instead of just Shipping.



Part II

A new page will need to be added for managing the Shippers, i.e., inputing the name, zipcode and handling fees and whatever else that is needed (free shipping options?).




Part III

This part has to modify the following:

1) Order Receipt that is emailed to the customer
2) Orders Admin page


These pages need to reflect excactly what was shown on the checkout_shipping.php page.





Steps:

I would start with the hardest part first, this would be the query that can start with a set of product_ids and determine how many shipping types are needed.

Then get n quotes from the shipping sites.

Display these quotes one on top of each other in the checkout page.

Add the "Remove Item" link to the displayed model numbers.

Sum the sub-totals for shipping to the Shipping Total.

Make the GUI interface for the Shipper table

Update the Orders Admin pages

update the order receipt that is email



I think that the orders table will need to be modified, and I hate to modify existing tables but in this case it will need a "shippers" column and look like this shipper_id/<shipper_cost>,shipper_id/<shipper_cost>,shipper_id/<shipper_cost>,...

We could use shipper_id or shipper_name, shipper_name may be better because if you remove a shipper or change its name that the shipper_id woun't find the original shipper name, so it may be better to just store it now and never have to go back and query for it ever again.

If you don't know how to parse this value, it is simple and a basic programming tool. The


The Shipping column must stay the same and must still be the shipping total for the order, the shipper column is just a break out of the shipping total for display purposes. Doing it this way will not break any other modules that still use the shipping column values and can buy us time for the Orders Admin and the Order Receipt that is emailed because I'm sure it is pulled from this column in this table.

I really think this approach won't impact many other modules except where most of the changes are made which is in the checkout_shipping.php page.


How does this sound? I can go either way on the name, shippers, vendors, etc.
blucollarguy
First, let me say, or write, that we have certainly created a little monster here haven't we? I think it needs to be done though, and I am somewhat surprised that it has not had more attention before. And I am overjoyed not to be in this alone!

This is exactly right, and what I have been trying to accomplish thus far, I have recently been pulled away for some other concerns.
QUOTE
the shipping class uses the cart class to get the products and coresponding vendors, it sorts the items by vendor, adds up the weights and calls the valid shipping modules for each vendor. it then returns the totals of all the different items and methods.

Joey:
QUOTE
If you have some products that ship on a truck while other products through the mail, but both are from the same vendor then a vendor list will not suffice.

Would this not be a shipping module, much like UPS or FedEx? If we created the table you are suggesting, which I agree would be needed for this mod to be as COMPLETE as possible, it seems to me that we are in effect creating another shipping module, which, like all the others in osC already(this was on my original list of desired features), could be enabled or not per Vendor. By creating this module we would have in the process the page to manage each shipper, ie, optional fees or charges. We will still need, I agree, an additional field for per product shipping charges and dimensions. As Stuart already mentioned, UPSXML supports dimensions, but the others don't. So in order for this to work properly, we need to update the other shipping modules to support dimensions, this does not seem to me to be a very difficult bit of code as it would simply be added to the prod table and be included in the call for the quote. No additional tables need to be accessed for this to work. Perhaps some deeper knowledge of the shippers themselves may be needed. In fact I think there has been activity to this end in the contrib area.
So, if we did this then every Vendor and every product would have the additional shipping option available, say Freight, for example, if the "dimensions" field were filled in for the particulart product and the Vendor had that ship option enabled. This way, one would not have to create several different "Shippers" per se, but would have all possibilities available from the new ship module. Creating this module may be a bit over my head. But if we intend to be able to call for quotes from other shippers, then this will need to be done.

We will need to have all of this info show correctly to the customer as well as to the store. So, Joey, you are on there as well. I do think we will need some text to explain to the customer that some prods come from different locations and that is why the shipping charges are broken down this way. Some of the products you have chosen will ship from different locations. We apologize for any inconvenience. Or something to that effect.
blucollarguy
BTW, during my first attempt to alter the chopping_cart class, I encountered the fact the onfo is stored in a "session" at this point. I am so unfamiliar with sessions that it initially intimidated me, and I stopped. But, after going back and looking at what I had gotten done, I think I already have the data collected and stored. But I'm not sure. If any one can offer any tips or quick explaination on working with sessions, I would appreciate it greatly.
joeyjgarcia
I think we are all stepping into areas that we are a little unfamilar and intimidated with, I know I am when it comes to tinkering with the checkout process a shipping modules. You don't really want to mess things up, or make it too complicated.

Sessions are not that bad. What I've learned from looking under the hood of osC is if you use their main functions for creating all your links, then their functions will put the session code in the right place, so you don't have to even concern yourself with it.

When you get a quote with the default shipping modules what is needed? Zip Code and Weight and maybe dimensions? Then why not try to keep things a close to the existing code but just get multiple quotes passing the weight and the zip code for each quote? For packages that require dimensions, would we be ok just adding a flat rate handling/shipping fee on top of the quote?

The shipping module is something that I haven't really looked at, so my questions are from pure ignorance.

Joey
zebrax
I am using 3 different shipping modules that use dimensions ,Fedex,DHL and Canada post. I have had to modify all of my shipping modules to reflect my stiuation. The dimensions can either be retreived via the cart or passed via a global array.

I have changed all my modules to give quotes for items that don't exist in the cart. We use shipping quote links on all our ebay auctions, that uses osc shipping modules to give a quote by passing the dimension and weight.

I don't see any way of getting around modify ALL shipping modules to work with multiple vendors. But the change should only be a few line here or there.

Adding a handling fee for large packages in not an option, we have tried it. Then we found out that sending large boxes uses the dimensonal weight , so for certian size boxes if you were to fill it with feathers and it would be billed at 72 pounds!!



If we had venders associated with the shipping compays they support then most default items would use those modules.

But for special items they can be set to use specific modules and over ride the vendors defaults, say for large items going on a pallet.

I don't think there is any variables in sessions that are needed, most are found in cart and order classes.
blucollarguy
I'll work with that about the sessions and see if I can get a quote.
I am also going to look at a few other shipping contributions to see if any are doing anything close to what we are looking for as far as functionality. For instance, I know there is a module that claims to offer per product shipping. I have no idea how they have done this, but it may be helpful to see how others have done things.

The ship info used in the standard shipping modules is STORE zipcode directly from the configuration table, and the weight from the products table. Adding simple charges to any given quote would be fairly easy. Even to sort it by Vendor and product would not be that difficult once we have achieved the proper code to get the quote we need using the info from the Vendors table linked properly to the appropriate product. The shopping_cart file in the classes directory is where all this takes place and is where we must convert the info from the product and STORE tables to Vendor and product table and sort and show the customer the quote. This file has a lot going on and it was a little scary for me at first. But I will try again.
joeyjgarcia
I would be very leary of use any other contribution other than for pure reference, but once you see it it is hard to not do the exact thing you saw.


Here is what I would recommend you starting. Do a test order (but don't confirm it) and put at least 4 products in the order from at least 2 different manufacturers then do that query that I mentioned that, in this case, counts how many manufacturers are involved in this order and set that as the For Loop limit, then sum the weight of the products for manufacturer A and get a quote with that manufacturer's zipcode then do the same thing in for manufacturer B and display them in the checkout_shipping page.

This really shouldn't be too hard, I would thing that summing the product's weight for each manufacturer is the trickest part, and that isn't too bad.

I would highly recommend a pure solution versus a piece from this contribution and a piece from that contribution. If something goes wrong we want to be able to know exactly why we did what we did.

I think this is the hardest part, so if this can be done then you can easily change the query to search the vendors table versus the manufacturer table.

I have a shipping contribution installed that limits what options the user has for shipping and I need to keep this so this is why I really don't want to go too far outside the boundaries incase we really have to. Looping (doing the same thing n times) doesn't really change things too much. Simplier is safer.

If you can try this I think we can all do the rest very easily. What do you think?

Joey
blucollarguy
Sounds like a good start, Joey. My intent in looking at other mods is a matter of reference, not necessarily to get code. I have accomplished a great deal by learning from methods used for other purposes and implementing them for my needs.
QUOTE
Looping (doing the same thing n times)

How would this code look? Assume I have all the necessary data, and am prepared to request the quote, the only code I am used to using is a "for each", or using a "sort" to create a list ordered by whatever, in this case Vendor id or Vendor zip would be best. I have already added multiple fields to my Vendors table for testing this mod, so I can work directly with that table. My thought is to create the product list from info from the Vendors table and the Products table, sorting by Vendor Id or Vendor zip.

I have, I think, gotten this part done. So now, how do I create this "loop" and format it so it is presentable to the customer? I am not a programmer, I just get done what I need to get done. Learning as I go. I created VA_Email this way, along with much input from a few other interested people who offered several suggestions and comments about what I had and what would be more useful. I think I came up with a decent mod that is quite functional. And we can do the same here. Together, we can create something very good here I think. smile.gif
cyanide
LOL rolleyes.gif This looks like a 3-person discussion.
I'm really quite surprised there hasn't been more interest !

Anyhow, I'm very interested in this module. My php coding (from scratch) is limited, but I would be happy to help anyway I can.... suggestions, beta testing, etc.
So, far looks like you are on the right track

Cheers, guys !
joeyjgarcia
blucollarguy:

I'll post something later today to help you out, it will be some psuedo-code that will show how to do what I am talking about.

A For Loop looks like this:

for($i=0; i<$limit; i++){



}

The $limit can be set using that query to determine the number of vendors involved. That query will need to use the "distinct" keyword to removed the common occurances in the resultset and you will need to use the count() aggragate function to count the number of unique vendors.

Something like this:

select count( distinct vendor_id) from vendors where product_id in (12, 13, 14, 35)

I'm not sure of the exact location of the distinct keyword, but try it without the distinct keyword first to get it working. The "in" function is a cool one, you might want to look that up, but it looks in a set of values, in this case a set of product _ids.

$i++ increments the variable of $i on each iteration.

generally the for loop looks like this:

for( <initialize>; <test>; <increment>){

}

Increment can count up or down.

The best way to learn about php is use thier on-line manual, I use it all the time. To use it for a for loop, just type http://www.php.net/for and it will take you straight to that page in the manual.

Gotto go to work now.

Joey
joeyjgarcia
Here is how it would look to obtian the vendor info and do a loop for each quote.


I would use a query like this to get the variable you need loaded.

$arrVendorInfo = new array();
$arrAllVendors = new array();



//To load the $arrAllVendors array, try something like this

$result = mysql_query("SELECT vendor_id, vendor_zipcode, vendor_fees from vendor where ....");

$index = 0;
while ( $row = mysql_fetch_array($result) ) {

$arrVendorInfo("vendor_id" => $row["vendor_id"],
"vendor_zip" => $row["vendor_zipcode"],
"vendor_fees" => $row["vendor_fees"]);
$arrAllVendors[$index] => $arrVendorInfo;
$index++;

}


$debug = false;

for( $i=0; $i < count($arrAllVendors); $i++){

if( debug) {
echo " Vendor ". $i . "'s id: ". $arrAllVendors[$i]["vendor_id"] ."<br>";
echo " Vendor ". $i . "'s zipcode: ". $arrAllVendors[$i]["vendor_zipcode"] ."<br>";
echo " Vendor ". $i . "'s fees: ". $arrAllVendors[$i]["vendor_fees"] ."<br>";
}

$vid = $arrAllVendors[$i]["vendor_id"];
$zipcode = $arrAllVendors[$i]["vendor_zipcode"];
$fees = $arrAllVendors[$i]["vendor_fees"];

//Get quote now (same as existng process)

//display results of shipping quote (same as existng process)

//Loop through again and get another quote in a new table row

}



MySQL Reference Manual:
http://dev.mysql.com/doc/mysql/en/index.html

Count Reference:
Counting Rows: http://dev.mysql.com/doc/mysql/en/Counting_rows.html

Distinct Reference:
http://dev.mysql.com/doc/mysql/en/DISTINCT_optimisation.html
zebrax
I started to code this now,
so far I have this
CODE
$prodvendors=$cart->get_products();
    foreach ($prodvendors as $product){
    $sortvendor[$product['vendors_id']]['vendors_id']=$product['vendors_id'];
   $sortvendor[$product['vendors_id']][]=$product;
   $sortvendor[$product['vendors_id']]['weight']+=$product['weight'];
   
   }
 
    
foreach ($sortvendor as $vendor){
$vendor_info_query=tep_db_query("Select * from vendors where vendors_id='".$vendor['vendors_id']."'");
$vendor_info=tep_db_fetch_array($vendor_info_query);
$sortvendor[$vendor['vendors_id']]=array_merge($sortvendor[$vendor['vendors_id']],$vendor_info);
}


You end up with an array of all the products order grouped by vendor with the vendor infomation in an array
blucollarguy
Actually Colin, I think you make number 4! We'll take all we can get if we can get this thing done right.

This is great guys, I was a lot closer than I thought. My queries were fine but getting them into the array and sorting the lsit properly was troubling me a bit. I will work with this and let you know how it goes from my test shop. I am going to keep it simple at first. Just get the quote with the correct Vendor zipcode and I think we'll have it beat. From there, adding additional info wont't be very difficult at all. So I will push for the quote first, and we'll go from there. Thanks for the code help wish me luck. Craig smile.gif
joeyjgarcia
Yes! Craig, I think you understand it now. If you get past that part everything else will be easy.

zebrax I'm not sure about your approach because you would need to know the vendor_id to get the data out.

The reason I did mine my way was if you want to display the contents of the array using a For Loop, you just need to fill in the value for the array index which starts at 0 to the length of the array and a For loop takes care of all that for you.

Either approach is a multi-dimensional array, I didn't want to say this because that term scares people and they can get pretty hairy quick. It would be ideal to make a vendor class that will allow us to create a vendor object that may look like this.

$objVendor = new Vendor;

Load the object fields like this:
objVendor->id = 10;
objVendor->zipcode = 12345;
objVendor->fees = 2;

Get them out like this:
echo objVendor->id;
echo objVendor->zip;
echo objVendor->fees;

These object can also be put into arrays.



Here are some references on PHP Classes.

http://www.zend.com/manual/language.oop.php
http://www.phpbuilder.com/columns/rod19990601.php3
blucollarguy
I will work with the classes a bit as well, but for now I just want a quote!LOL
zebrax
I am already using a higly modified vendors mod. The becuase of my situation each product can only have 1 vendor. We actualy have 2 different locations and sell the same stuff on one website. Because we have a lot of local customers to both locations ve need to alow customer to search localy so they can pick up there items. The cart load the vendor id with each product , so that is why I created the code above, becuase I did know the vendor id.

I am going to code for my situation and you guys can have a look at it and change things as needed.
blucollarguy
Okay folks, I am a bit stumped. I am pretty confident that I have collected the Vendor Zip, defined it so it can be passed easily from file to the next, and changed
QUOTE
$this->_upsOrigin(SHIPPING_ORIGIN_ZIP, $country_name['countries_iso_code_2']);
to
QUOTE
$this->_upsOrigin($vendors_zipcode_list, $country_name['countries_iso_code_2']);

BUT! No quote. I am calling for a quote for only one product for testing purposes, so I will not yet need to loop for more quotes. So I have tried to track down exactly where this
QUOTE
$this->_upsWeight($shipping_weight);

particularly "$shipping_weight" , gets defined. This is the only variable that comes directly from the products that are in the cart that gets used for the quote. My logic being, find where this is defined and I will know exaclty where to define all the Vendor info. Problem is, I can't find it. Exactly.

In cat/inc/classes/shipping.php you will see
QUOTE
function quote($method = '', $module = '') {
      global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;

      $quotes_array = array();

      if (is_array($this->modules)) {
        $shipping_quoted = '';
        $shipping_num_boxes = 1;
        $shipping_weight = $total_weight;

Note "$shipping_weight = $total_weight;" , yet both are defined as GLOBAL variables. I cannot find specifically where these begin.
Possibly in /*/*/calsses/shopping_cart.php where this code
QUOTE
function show_total() {
      $this->calculate();

      return $this->total;
    }

    function show_weight() {
      $this->calculate();

      return $this->weight;
    }
But I am not sure and my first several attempts to define the Vendors Zip have not worked. Any ideas or suggestions?
joeyjgarcia
Did you print out $vendors_zipcode_list before you obtained your quote? make sure it prints out a value that makes sense and that you are not sending mulitple numbers (the "list" part of the name makes me think that).

Here is what my search yielded.

Searching for: $shipping_weight
\catalog\includes\classes\shipping.php(45): global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;
\catalog\includes\classes\shipping.php(52): $shipping_weight = $total_weight;
\catalog\includes\classes\shipping.php(54): if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) {
\catalog\includes\classes\shipping.php(55): $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT;
\catalog\includes\classes\shipping.php(57): $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100);
\catalog\includes\classes\shipping.php(60): if ($shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes
\catalog\includes\classes\shipping.php(61): $shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT);
\catalog\includes\classes\shipping.php(62): $shipping_weight = $shipping_weight/$shipping_num_boxes;
\catalog\includes\modules\shipping\table.php(49): global $order, $cart, $shipping_weight, $shipping_num_boxes;
\catalog\includes\modules\shipping\table.php(54): $order_total = $shipping_weight;
\catalog\includes\modules\shipping\ups.php(71): global $HTTP_POST_VARS, $order, $shipping_weight, $shipping_num_boxes;
\catalog\includes\modules\shipping\ups.php(88): $this->_upsWeight($shipping_weight);
\catalog\includes\modules\shipping\ups.php(94): 'module' => $this->title . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . 'lbs)');
\catalog\includes\modules\shipping\usps.php(65): global $order, $shipping_weight, $shipping_num_boxes, $transittime;
\catalog\includes\modules\shipping\usps.php(76): $shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);
\catalog\includes\modules\shipping\usps.php(77): $shipping_pounds = floor ($shipping_weight);
\catalog\includes\modules\shipping\usps.php(78): $shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight)));
\catalog\includes\modules\shipping\usps.php(82): $shiptitle = ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . 'lbs)';
\catalog\includes\modules\shipping\zones.php(116): global $order, $shipping_weight, $shipping_num_boxes;
\catalog\includes\modules\shipping\zones.php(140): if ($shipping_weight <= $zones_table[$i]) {
\catalog\includes\modules\shipping\zones.php(142): $shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY . ' ' . $dest_country . ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONES_TEXT_UNITS;
Found 21 occurrence(s) in 5 file(s)


I use TextPad for programming in osC, I've tried all the others out there and they seem too slow or they don't offer features that are really needed for hacking osC, such as a fast Global Search or line wrapping. If you want a copy, I'll send you my copy.

I hope this helps you.

BTW, I hope you are making backups.

Craig, you are doing a great job!!!

Joey
blucollarguy
I have so many different copies of my shop in different stages of developement that I often get confused as to which is my "Live" shop. LOL

I will look at TextPad and see if it makes anything easier for me.

As you can see from your search, there does not seem to be a definitive spot where $shipping_weight gets defined. My best guess is in /*/*/calsses/shopping_cart.php
QUOTE
function show_total() {
      $this->calculate();

      return $this->total;
    }

    function show_weight() {
      $this->calculate();

      return $this->weight;
    }

At the "return" point, I think it is creating the "$shipping_weight".
So, what I have been working on is writing a "function" to properly create the zip data. I do need to print the "list" and make sure it is what I think it is. To simplify things to start with, I am only using 1 product for the quote, so there can be only 1 zipcode being used, if it is collected properly to begin with. I am going to use your search as ref and check some more files before I strain my brain too much more in the same spot. Sometimes, I have found that if I look away for a while the answer becomes so clear when I get back to it. Thanks Joey, for the encouragement and suggestion. smile.gif
joeyjgarcia
I was doing something else and ran across some code that I think you will need.

Here is an example of some osC code that stuffs values into an array the easy way. If you want to make a vendors array you might want to do it this way.



while ($vendors= tep_db_fetch_array($vendors_query)) {
$vendors_array[] = array('id' => $vendors['vendors_id'],
'zip' => $vendors['vendors_zip'],
'fees' => $vendors['vendors_fees'],
);
}

You get it out like this: $vendors_array[$i]['fees']

the $i variable will the index used in the For Loop, when you do your looping.

Joey
joeyjgarcia
Since $shipping_weight is a simple variable you won't fine it "defined" per se, instead you'll find that that variable was created and set to a value, possibly from calling a function and the return value sets the value of $shipping_weight.

Always test your data before you use it, typically this is the biggest mistake programmers have, they assume the data they are using it correct only to find out downstream that their variable is empty or something else. I print out my values for every step, especially if there are other functions, loops, etc. that are dependent on that variable's value. I use an if statement that has a "debug" variable that I can change the value from true to false to see values printed out, I put an example of that in a previous post.

I would also support your idea to take breaks, a lot of times a drive is a good time to see your answer because you think while you drive, just don't get into an accident we need you!! smile.gif

Joey
blucollarguy
Thanks Joey, I have worked with that basic code structure(the array) before and will need your example when it is time to create the loop for multiple quotes. I have started a bit of a re-write to include the "debug" info and your right, $shipping_weight isn't actually defined, it is created through a function. I am moving forward from here so wish me luck.
smile.gif
Craig
blucollarguy
FRUSTRATION!!!!!!!!!!!!!!!!!!!!!!!!!

I know I am retrieving the info, I can echo it no problem. Just can't figure out how to pass it to the ship module! Breaktime. Anyone with ANY suggestions?

Craig smile.gif
blucollarguy
Alright now, this is dirving crazy. Look at the following code
QUOTE
function show_total() {
      $this->calculate();

      return $this->total;
    }

    function show_weight() {
      $this->calculate();

      return $this->weight;
    }
    //mlti vendor
    function show_vendors_postcode() {
    $this->contents();
    return $this->vendors_postcode;
    }
    function show_mlti_weight() {
      $this->calculate();

      return $this->mlti_weight;
    }

    function generate_cart_id($length = 5) {
      return tep_create_random_value($length, 'digits');
    }

    function get_content_type() {
      $this->content_type = false;

echo " Vendor's id: ". $vendors['vendors_id'] ."<br>";
echo " Vendor's zipcode: ". $vendors['vendors_zipcode'] ."<br>";

Why you ask? Because something about this is "breaking" the data from the Vendor array.

Here is what I did. I have been on a rabbit hunt with this, and I see little "ears" everywhere, so bare with me. As I posted B4 I have collected the data in the shopping_cart class. Passing it to the ship module is the hard part. So I started adding some "echo" satatements at different points in the file. The code above is when I lose the data. Add the "echo" statements above this code, anywhere above this code and we can see the data printed on the screen.

Thus, the question is why? Suggestions? Craig smile.gif
joeyjgarcia
There is a cart class because I can see a cart object, I think what needs to happen is create a method in this class. Methods are the class equivalent of functions. Once the cart class is found a method called getVendorCount() needs to be added.

When making methods for classes you always want the method names to be verbs, and it is a typical practice to use getters and setters, which look like this:

Examples:
$cart->getOrderTotal();
$cart->getShippingQuote();
$cart->getVendorCount();


$cart->setDiscount( $discount );
$cart->setShippingMethod( $selectedShippingMethod );

It would cleanest to do the dirty work there.

Remember, 1 cart and multiple: vendors, weight, contents, zip codes


I am starting to look under the hood of this shipping stuff because I'd like to do this right the first time since it is so critical.

Joey
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.