blucollarguy

Multi_Vendor_Shipping new thread

4,998 posts in this topic

I don't understand your last post?

 

 

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

Share this post


Link to post
Share on other sites

All of the work I have done so far is in */*/classes/shopping_cart.php This is the file tath collects the data and somehow, makes it available to all other files. This is also where the data is added to the db, customers_basket, and order.

 

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

Share this post


Link to post
Share on other sites

A little info on what I have done, the vendor query immediately follows this product query

if (!is_array($this->contents)) return false;

 

      $products_array = array();

      reset($this->contents);

ofcourse, the rest of the "product query" and then the Vendor query:

//mlti vendor

                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>"

and at this point the echo returns the data no problem. The data does not make it to the ship module though. And keep in mind that I am working with a modified Vendors tables from VAEmail, I added several fields for the different fees to be called without sql errors.

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:

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;

.

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 :)

Share this post


Link to post
Share on other sites

Ive just realised that this thread is in "contribution support". It should be in "shipping modules" so we might be able to get input from some of the minds that have created some of the shiiping modules themselves. I am going to PM a request to move this entire thread to the "shipping modules", so if anyone loses track of this thread, it should be there. I have seen it take several days to make this kind of change. Just to let everyone know. Craig :)

Share this post


Link to post
Share on other sites

I am currently writing a new version of the MVS(multi_vendor_shipping) to be able to use a Vendor zipcode instead of the STORE zipcode. I have successfully attached a Vendor and all their relevent info to the product and can collect the data from the cat/includes/classes/shopping_cart.php file. I am having trouble passing the zipcode to the shipping module. I know I will need to change the call for the STORE zip in each module, but I have not figured out how to make the Vendor zip show in the module. Is there a particular place in class file, shopping_cart, or another file where this needs to be specified? And how? Any help will be greatly appreciated. Several folks have been trying to work with me on this through the following thread:

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 :)

Share this post


Link to post
Share on other sites
I am currently writing a new version of the MVS(multi_vendor_shipping) to be able to use a Vendor zipcode instead of the STORE zipcode. I have successfully attached a Vendor and all their relevent info to the product and can collect the data from the cat/includes/classes/shopping_cart.php file. I am having trouble passing the zipcode to the shipping module. I know I will need to change the call for the STORE zip in each module, but I have not figured out how to make the Vendor zip show in the module. Is there a particular place in class file, shopping_cart, or another file where this needs to be specified? And how? Any help will be greatly appreciated. Several folks have been trying to work with me on this through the following thread:

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  :)

As you can see this is done, so I hope nobody gets lost. Anyway the previous post for help from anyone with experience with the shipping codework still applies. Thanks for all the input so far, we will beat this thing Guys.

Craig :)

Share this post


Link to post
Share on other sites

Replaced my bookmark, good idea.

 

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?

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.

 

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.

Where exactly are you doing this?

 

 

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

Share this post


Link to post
Share on other sites

That code is towards the bottom of the scrip, in catalog/admin/includes/classes/shopping_cart.php. You are probably looking in the catalog/shopping_cart.php[?I] file. We may need to add code to that one too, but for now I am confident that what we need to accomplish is the */*/classes/shopping_cart.php file.

 

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

Share this post


Link to post
Share on other sites
That code is towards the bottom of the scrip, in catalog/admin/includes/classes/shopping_cart.php. You are probably looking in the catalog/shopping_cart.php[?I] file. We may need to add code to that one too, but for now I am confident that what we need to accomplish is the */*/classes/shopping_cart.php file.

 

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

 

SORRY!

Edited by blucollarguy

Share this post


Link to post
Share on other sites

That helps. I thought the admin path would clarify my confusion, but ... .

 

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! :D

 

 

 

Joey

Share this post


Link to post
Share on other sites

Appreciate the support Joey, I know about other responsibilities, I am fortunate at the moment, my 11 year old son just got back from 10 days at camp and just wants to chill and watch NASCAR and play games on the laptop, my wife generally takes Sundays off to catch up on rest. So this is my day to focus on whatever I want (my shop, at this point is not really work, it is Sunday) so I understand your other needs.

I have never been one to quit too easily, we will get this done, I firmly believe that this could be incredibly valuable to a lot of people. So, when you get something, let me know. Craig :)

Share this post


Link to post
Share on other sites

A quick note:

Searched like crazy to find some answers. Tried code to save v-zip directly to session, no luck. Tried querying form the ship module directly, customer_id, basket_id and therefore products_id not accessible. Posted a request for explanaination of how the info gets to ship modules in the "general discussion" section, no response so far. Not sure where to go to find this info, but it must be out there some where. We are stuck until we figure this part out. Craig :)

Share this post


Link to post
Share on other sites

Ok, give me a task and I'll work on just that.

 

Export your table structure of your new table(s) and I'll put in my own rows so we have that in common.

 

Joey

Share this post


Link to post
Share on other sites

Joey, blucollarguy, et al.......

 

I wanted to add my 2 cents to the conversation and provide everyone with a synopsis of how our company was looking to enhance the original MVS:

 

- Vendor Based zipcode origins seem to be the most effective method of calling data from the mySQL tables;

 

- We currently have the original MVS running, along with a couple added shipping methods in place (Individual Shipping, Free Shipping, etc);

 

- Mike, the original author of EMVS (tahuti@netzero.net), has tried to work closely with our IT team to integrate global zipcode variables into his updated code. However, we were having problems since it appeared Mike wrote only a portion of the code needed to simply reference the zips from the Vendor table, but not an actual call to the shopping cart when checking out. The shopping cart class was running into problems and wasnt producing the correct shipping quote based in ziporigins.

 

- MVS and EMVS were also having problems with combining 2 or more items in the cart with 2 or more vendors/shipping origins. Perhaps this is a wrongly designed calculation function in the shopping cart?

 

********

 

On a personal note, I believe this new version of Enhanced Vendors will easily supercede older releases. The zipcode origin functionality alone is worth its weight in gold. This kind of contribution will make the concept of dropshipping very doable, and we hope to introduce the code into our family of websites.

 

Please let me know what I can do to help!

 

Thanks,

 

-Codi

Share this post


Link to post
Share on other sites

Glad to have you on board with us Codi, and enjoyed our conversation. I will look at things a bit differently while we work on this from our current direction, I would like to exhaust our efforts on this track before changing the "how" portion of what we are trying to accomplish.

 

Joey, which table do you want, the Vendors table? Here is the sql to create the Vendors table and add rows to "products" table

###SQL-query : Vendors Email

ALTER TABLE `products` ADD `vendors_id` VARCHAR( 11 ) DEFAULT NULL ;

ALTER TABLE `products` ADD `vendors_product_price` DECIMAL( 15, 4 ) DEFAULT '0.0000' NOT NULL ;

ALTER TABLE `products` ADD `vendors_prod_id` VARCHAR( 24 ) NOT NULL AFTER `vendors_product_price` ;

ALTER TABLE `products` ADD `vendors_prod_comments` TEXT DEFAULT NULL AFTER `vendors_prod_id` ;

 

# --------------------------------------------------------

# Table structure for table `vendors`

#

 

CREATE TABLE `vendors` (

  `vendors_id` int(11) NOT NULL auto_increment,

  `vendors_price_id` int(32) NOT NULL default '0',

  `vendors_contact` varchar(32) NOT NULL default '',

  `account_number` varchar(32) NOT NULL default '',

  `vendors_name` varchar(32) NOT NULL default '',

  `vendors_phone1` varchar(20) NOT NULL default '',

  `vendors_fax` varchar(20) NOT NULL default '',

  `vendors_email` varchar(64) NOT NULL default '',

  `vendors_url` varchar(64) NOT NULL default '',

  `date_added` datetime default NULL,

  `last_modified` datetime default NULL,

  `vendors_image` varchar(24) default NULL,

  `vendors_send_email` tinyint(1) default '0',

  `vendor_street` varchar(64) NOT NULL default '',

  `vendor_city` varchar(32) NOT NULL default '',

  `vendor_state` varchar(32) default NULL,

  `vendor_country` varchar(64) NOT NULL default '',

  `vendors_zipcode` varchar(11) NOT NULL default '',

  `vendor_add_info` text,

  `method_name` varchar(32) NOT NULL default '',

  `module_names` varchar(64) NOT NULL default '',

  `handling_charge` decimal(5,2) NOT NULL default '0.00',

  `handling_per_box` tinyint(1) NOT NULL default '0',

  `tare_weight` decimal(4,2) NOT NULL default '0.00',

  `max_box_weight` tinyint(3) unsigned NOT NULL default '0',

  PRIMARY KEY  (`vendors_id`)

) TYPE=MyISAM COMMENT='Vendors table add-in' AUTO_INCREMENT=34 ;

Everything is stored within these 2 tables, If you have not installed VA_Email, you can run this script as is, if you have it installed, you will need to add the following rows to the VENDORS table:

`method_name` varchar(32) NOT NULL default '',

  `module_names` varchar(64) NOT NULL default '',

  `handling_charge` decimal(5,2) NOT NULL default '0.00',

  `handling_per_box` tinyint(1) NOT NULL default '0',

  `tare_weight` decimal(4,2) NOT NULL default '0.00',

  `max_box_weight` tinyint(3) unsigned NOT NULL default '0',

Note that at this point in our progress I have not botheres to call for the addinitional info you see in the Vendors table here, just the zipcode. But you can see that it is a copy of what was being used in the original MVS contrib. I can explain this portion further if you want, but I think you can see what would be available from each Vendor.

 

If there is any other info you need, just let me know. If you want a copy of the */*/classes/shopping_cart.php file or any of the other files I have worked with, email me and I will email all related files for you to see what I have done.

 

It still comes down to "how" we will pass the "vendors_zipcode" to the ship module itself. After talking to Codi, we have a couple of other possibilities. I will explore them a little further before posting anything on those. For now, I think we should continue on our current track. Lets see what we can do! Craig :)

Share this post


Link to post
Share on other sites

Great, something I can focus on. I'll install your vendors table and use a query to get the zip code and I will work on passing this to the shipping module.

 

Joey

Share this post


Link to post
Share on other sites

I have already said how to pass the zip code to each module. You NEED to modify each module. Most modules use a contant SHIPPING_ORIGIN_ZIP for the zip code. This can't be changed. You need to use a global variable that can be changed.

 

 

The whole concept of this thread isn't hard. When I get an extra hour I will show you that it can be done.

Share this post


Link to post
Share on other sites

Ok Dax, we already know we need to change call in each module, DUH!!!!!

How? I have gotten the queries to collect the data in the classes/shopping_cart.php no problem, but I have not been able to successfully pass that info to the module by any means. If you know how to store the info once we have collected it please post that instead of a snotty post implying I had not read your previous post. Apparently, you did not bother to read the last page or 2 of this thread or you would have know that.

 

Craig :)

Share this post


Link to post
Share on other sites

Apparently you didn't read my posts on the second or third page, becuase when I follow what I have said, its amazing! I get quotes back using different postal codes. Now all I have to do is sort and display them.

but apparently you don't want my help here, so BYE.

Share this post


Link to post
Share on other sites

Ok Dax, I have gone back and checked, this is what I found.

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....

and

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

And I woked a bit with the code you posted here but I could not follow you well enough to not get constant errors. I apologize for jumping on you, but you seem to think that you had already resolved our issues and I had chosen to ignore you. Not the case at all. We all need to work together and get this done so we can all get what we need. If there is something in your posts that shows how the zipcodes make their way to the shipping modules, POINT IT OUT TO ME because I am apparrently too stupid to see it. It's up to you, we can work together, or you can take your ball and go home, and we will just keep struggling along until we work it out.

We need all the help we can get.

blucollarguy 

Posted: Jul 12 2004, 06:11 AM

Craig Garrison Sr

 

 

 

Group: Community Member

Posts: 164

Joined: 25-April 04

 

 

 

 

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.

As I said from the beginning, I am no genius. Craig :)

Share this post


Link to post
Share on other sites

My shipping.php class contains this code in th quote function

global $origininfo;
$origininfo['zipcode']=$vendor['vendors_ship_zip'];
$origininfo['country']=$vendor['vendors_ship_country'];
$origininfo['state']=$vendor['vendors_ship_state'];

 

then each module need to has code likethis also in the quote function.

global $origininfo;

$countries_array = tep_get_countries($origininfo['country'], true);
       $this->country = $countries_array['countries_iso_code_2'];

$this->originZip=$origininfo['zipcode'];

 

 

of coarse each module sets the zipcode and country in a different place.

 

 

I set the top code in a loop for all of the vendors, which gives me a shipping quote for each vendor. I now have to combin the array and display the contents and have that quote get carried over to the next step of the checkout process, ( 1 quote can contain multiple quotes from different shipping companies) th current way will not work.

Share this post


Link to post
Share on other sites

Thanks for comoing back Dax. I will see if I can work with what you have started. A few questions so I can understand what you are doing. Obviously, you are creating the global variable $origininfo, I assume the query to get this info will happen in catalog/includes/classes/shopping_cart.php, yes?

This is where it has been breaking for me, what is the code to carry or define what we get from the query? I have been able to get all the data, but I have not been able to retain it all the way through to the ship module. Can you explain how this works? Craig :)

Share this post


Link to post
Share on other sites

It just hit me. You are storing the $originingo in the session. I tried that but, looking at your code now I think I see what I was doing wrong! We still need to define $origininfo from shopping_cart class though, right?

Like this?

//mlti vendor

    function show_origininfo() {

    $this->contents();

 

    return $this->origininfo;

    }

At the end of the classes/shopping_cart file?

Share this post


Link to post
Share on other sites

Stress in settling in, sorry I haven't had any time to help out so far.

 

Zebrax, your suggestion is helpful!

 

Craig, I think I finally understand your problem because you said it yourself, sessions. If I understand you corectly, you want to know how to carry the data to the next page? I figure this is only a small part of the bigger problem but a very basic necessity. Global variables are not the same as Session variables, global variables are usable in every function where local variables are usable only in that function, session variables would be usable in every page, and function. Session variables are officially registered (see http://us2.php.net/session).

 

I hope this help a little. I apologize if I still misunderstand.

 

I'll take a closer look at Zebrax's code example.

 

Joey

Share this post


Link to post
Share on other sites

Sessions are not used for the shipping cost until, a specific shipping method is picked. The method is picked on checkout_shipping.php page using an input variable with name=shipping and value in the form of "module_method" eg "fedex_express" When this info is posted back to chekout_shipping.php it calls the shipping module again and gets the value of "method" at that time it creates a session called shipping with the choosen method price and title,etc, it then redirects to checkout_payment.php.

 

So at no time do we need to directly set the session with the shipping info, it should be done automaticly when the method is chosen. But this is where the problems start. We are using multiple modules and methods so the standard input of "module_method" will not work in our situation. we may have to change it to somethng like "vendor_number" where the number would be the quote that could consist of many modules and method prices added together.

 

example

2 items from vendor A

1 item from vendor B

 

Vendor A ships with UPS

Vendor B ships with Fedex

 

For 1 box from Vendor A would would have a few methods: Ground and express

the same for box 2 from vendor B: ground and Express

 

so now you have a quote 1 which is ups ground and fedex ground added together.

and quote 2 for UPS express and Fedex express.

 

now the customer would choose the shipping they want..normaly that would be posted as fedex_express or ups_ground but we could change that to vendor_1

 

so now the price for quote 1 get entered into the session with title "2 boxes fedex and UPS" and price "$" and the checkout process continues as normal.

 

I understand that we could end up with multiple methods and multiple modules, and it could be very confusing. But we should be able to manage it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now