Multi_Vendor_Shipping new thread
#41
Posted 30 July 2004 - 10:25 PM
I am going to code for my situation and you guys can have a look at it and change things as needed.
#42
Posted 31 July 2004 - 10:45 AM
Quote
Quote
Quote
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
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;
Possibly in /*/*/calsses/shopping_cart.php where this code
Quote
$this->calculate();
return $this->total;
}
function show_weight() {
$this->calculate();
return $this->weight;
}
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#43
Posted 31 July 2004 - 02:07 PM
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
#44
Posted 31 July 2004 - 02:56 PM
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
$this->calculate();
return $this->total;
}
function show_weight() {
$this->calculate();
return $this->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.
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#45
Posted 31 July 2004 - 03:05 PM
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
#46
Posted 31 July 2004 - 03:14 PM
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!!
Joey
#47
Posted 31 July 2004 - 04:36 PM
Craig
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#48
Posted 31 July 2004 - 09:41 PM
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
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#49
Posted 01 August 2004 - 02:35 AM
Quote
$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
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#50
Posted 01 August 2004 - 04:01 AM
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
#51
Posted 01 August 2004 - 04:07 AM
Where is your problem?
The function get_content_type() is incomplete.
Which line is throwing errors? What it printing out? What do you expect for the print out?
When you need help post the page name and the function name so I can understand the context of your question.
Joey
Edited by joeyjgarcia, 01 August 2004 - 04:11 AM.
#52
Posted 01 August 2004 - 10:52 AM
I have collected the data from the Vendor attched to the products in the customer's basket. I am printing the Vendor ID and Vendor zipcode from there. The print shows in the shopping cart from every page that has the cart included. The previous post was to show that as I tried to track the echo through the entire script, litreally moving the position ot the echo line down in a few steps at each attempt. My thinking being, perhaps something is breaking the info before it gets to the ship module. Once I put the echo beyond where "funtion show" begins, the data no longer prints.
Apparrently though, nothing else is effected in any way since when I test the ship module with it's standard STORE zip entry, I get the quote no problem.
Every effort I have made to in some way make the Vendor zip available to the ship module has not worked despite the fact that I KNOW the data is there. In our previous post, you showed one of the many code attempts I have made. I am going to breakdown what I have tried and post it so we can all look at it together. I can show my query, and show several attempts at holding the data for the ship module to then call to.
Another "call" from the ship module we may be able to track to find the right spot is "$order". I think this is stored in the "sessions" table, but I can't find where it gets put together. I'll show more code soon. Craig
ps I emphatically agree that we need to do this right, which is why I started this thread so I would not ba allowed to screw it up all by myself! LOL
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#53
Posted 01 August 2004 - 11:52 AM
Quote
$products_array = array();
reset($this->contents);
Quote
if (!is_array($this->contents)) return false;
$vendors_array = array();
reset($this->contents);
while (list($vendors_id, ) = each($this->contents)) {
$vendors_query = tep_db_query("SELECT v.vendors_id, v.vendors_zipcode, v.handling_charge, v.handling_per_box, v.tare_weight, v.max_box_weight, v.module_names from vendors v, products p where p.products_id = '" . (int)$products_id . "' and v.vendors_id=p.vendors_id ORDER BY p.vendors_id");
$index = 0;
if ($vendors = tep_db_fetch_array($vendors_query)) {
$vid = $vendors['vendors_id'];
// $vendor_handling = $vendors['handling_charge'];
$vendors_postcode = $vendors['vendors_zipcode'];
// $vendors_zipcode = $cart->show_vendors_zipcode();
}
$vendors_array[] = array('id' => $vendors_id,
// 'ship_method' => $vendor_module_list,
'vendors_postcode' => $vendors['vendors_zipcode']);
echo " Vendor's id: ". $vendors["vendors_id"] ."<br>";
echo " Vendor's zipcode: ". $vendors["vendors_zipcode"] ."<br>"
So I have tried several "function" calls as shown in my earlier confusiong post and I get the error "Cannot re-declare class, vendors_zipcode, already sustantiated(or whatever it says) in", which indicates to me that the data is in fact stored, but where, and how do we call if from the ship module.
Immediately following this query, is this script I posted earlier:
Quote
$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;
The "mlti_weight" function will be needed to add the additional fees to the weight from the products. We can add ANY other fees here as well, per Vendor, or per product, or both since the calculation is done here and I know I can collect the data from the Vendors and Products tables. So it is just the zipcode we need to hammer out.
Once we get here with the echo, we no longer have data in the output. I am researching the */*/classes/shipping.php file to see if it is used to carry the data from the shopping_cart and pass it to the ship module. See any major problems? Keep in mind that if I change the zip back the STORE in the ship module and change nothing in the shopping_cart file, I get a quote. So none of this is breaking the data flow. What do you think? Suggestions on where to go from here? Craig
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#54
Posted 01 August 2004 - 12:04 PM
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#55
Posted 01 August 2004 - 12:14 PM
http://forums.oscommerce.com/index.php?showtopic=101973
I am gioing to request that my current thread be moved here so the MVS thread will be in a more appropriate place in the forums. Thanks for any help, Craig
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#56
Posted 01 August 2004 - 02:35 PM
blucollarguy, on Aug 1 2004, 08:14 AM, said:
http://forums.oscommerce.com/index.php?showtopic=101973
I am gioing to request that my current thread be moved here so the MVS thread will be in a more appropriate place in the forums. Thanks for any help, Craig
Craig
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#57
Posted 01 August 2004 - 03:55 PM
I was looking at you post at the top of the page and I was trying to follow but I couldn't seem to find the function "show" in the shopping_cart.php.
Is this in another file now?
Quote
Quote
I am trying to find exactly where you are, but sometimes you mention a file then you mention a module then you start referencing code and I'm not sure where you are.
I'd like to know what you are trying to achieve today so I can help you.
Joey
BTW, I downloaded a real PHP Editor that will help me see the PHP functions, variables and classes. You might try it out it is pretty handy. Here is the screenshot http://phpedit.com.ua/eng/screenshort.phpedit
#58
Posted 01 August 2004 - 04:44 PM
Sorry I have been confusing you. "Module" would be the shipping mdule itself, they are found in catalog/includes/modules/shipping/. I have been testing with the UPS module just because I have some familiarity with it from previous issues with my site. The other files I have referenced are:
catalog/admin/includes/classes/shipping.php and
catalog/shopping_cart.php
The */*/classes/shipping.php file is the one I have been playing with this morning, but no progress. I hope this clears up some of the confusion so we can get this part worked out today. If I had been able to get a quote already, we could have been working the details of what info we want from each Vendor and how to present it to the customer. Craig
ps I tested 5 or 6 php editors when I started working with osC, and I personally settled on PHP Expert Editor, tise link: http://www.ankord.com/ will take you to it if you want to check it out as well. Syntax highlighting can be very useful. It helps to show proper code.
This one was about $10 more on average than some of the others that I checked out, but it is very powerful, with an FTP facility, tag locator(find relative close/open tag), syntax check, support for HTML,XML, debugger, and if you have php support locally, it will run your scripts from popup. Lots of other stuff I don't use but probably will eventually. Just my personal taste, mind you, many others can do the same things.
Edited by blucollarguy, 01 August 2004 - 04:47 PM.
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#59
Posted 01 August 2004 - 04:52 PM
Quote
Sorry I have been confusing you. "Module" would be the shipping mdule itself, they are found in catalog/includes/modules/shipping/. I have been testing with the UPS module just because I have some familiarity with it from previous issues with my site. The other files I have referenced are:
catalog/admin/includes/classes/shipping.php and
catalog/shopping_cart.php
Not admin. These are wrong:
catalog/admin/includes/classes/shipping.php
catalog/admin/includes/classes/shopping_cart.php
These are right: catalog/includes/classes/shopping_cart.php
catalog/includes/classes/shipping.php
[I]SORRY!
Edited by blucollarguy, 01 August 2004 - 04:53 PM.
Craig Garrison Sr
Anything worth having, is worth working for.
Multi Vendor Shipping V1.1 Demo Catalog
3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.
Multi Vendor Shipping V1.1 Demo Admin
login: webmaster@blucollarsales.com
pass: mvs_demo
MVS Thread:
Multi-Vendor Shipping
My contribs:
Download Multi Vendor Shipping V1.1
Vendor Email
Vendor Info in easypopulate
EZ Price Updater
And more to come!
#60
Posted 01 August 2004 - 05:56 PM
Anyway, if looks like you are set as far as editors.
Craig, the way I see it when you break through this hard part the rest will be cake and fall together.
Sorry, for not putting in the same amount of hours you obviously are, I have to sneek over here in between family duties. During the day I spend time doing my "Honey Do" list and stuff with the kids for recreation, but in the evenings is when I get most of my coding time in.
I just want to understand exactly where you are and what your first objective is so when I get a small break of time I can go directly in the code and try to provide some answers.
I'm glad you don't quit easy! This is a huge effort when you consider the complexity of this contribution, I like to call efforts like this "Brain Surgery" because it is so critical.
Keep up the good work, Dr. Bluecollerguy!
Joey









