Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Multi_Vendor_Shipping new thread


blucollarguy

Recommended Posts

This is the code of vendor_order_data.php

 

<?php
/*
$Id: vendor_order_data.php V1.1 By Craig Garrison Sr. ([email protected]) for Multi-Vendor Shipping for MVS V1.0 2006/03/25 JCK/CWG
$Loc: /catalog/includes/ $
$Mod: MVS V1.2 2009/02/28 JCK/CWG $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2006 osCommerce
Released under the GNU General Public License
*/
//prende i dati dal link
    if (isset ($_GET['order_id']) && $_GET['order_id'] != '') {
 $order_id = (int) $_GET['order_id'];
 }
 $index2 = 0;
 //let's get the Vendors
 $vendor_data_query = tep_db_query("select orders_shipping_id, orders_id, vendors_id, vendors_name, shipping_module, shipping_method, shipping_cost from " . TABLE_ORDERS_SHIPPING . " where orders_id = '" . (int) $order_id . "'");

 while ($vendor_order = tep_db_fetch_array($vendor_data_query)) {
    $these_products[$index2] = array (
	  'Vid' => $vendor_order['vendors_id'],
	  'Vname' => $vendor_order['vendors_name'],
	  'Vmodule' => $vendor_order['shipping_module'],
	  'Vmethod' => $vendor_order['shipping_method'],
	  'Vcost' => $vendor_order['shipping_cost'],
	  'Vnoname' => 'Shipper',
	  'spacer' => '-'
    );
    $index = 0;
    $orders_products_query = tep_db_query("select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price, vendors_id from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int) $order_id . "' and vendors_id = '" . (int) $vendor_order['vendors_id'] . "'");
    while ($orders_products = tep_db_fetch_array($orders_products_query)) {
	  $these_products[$index2]['orders_products'][$index] = array (
		    'qty' => $orders_products['products_quantity'],
		    'name' => $orders_products['products_name'],
		    'tax' => $orders_products['products_tax'],
		    'model' => $orders_products['products_model'],
		    'price' => $orders_products['products_price'],
		    'vendor_name' => $orders_products['vendors_name'],
		    'vendor_ship' => $orders_products['shipping_module'],
		    'shipping_method' => $orders_products['shipping_method'],
		    'shipping_cost' => $orders_products['shipping_cost'],
		    'final_price' => $orders_products['final_price'],
		    'spacer' => '-'
	  );


	  $subindex = 0;
	  $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int) $order_id . "' and orders_products_id = '" . (int) $orders_products['orders_products_id'] . "'");
	  if (tep_db_num_rows($attributes_query)) {
		    while ($attributes = tep_db_fetch_array($attributes_query)) {
			  $these_products[$index2]['orders_products'][$index]['attributes'][$subindex] = array (
				    'option' => $attributes['products_options'],
				    'value' => $attributes['products_options_values'],
				    'prefix' => $attributes['price_prefix'],
				    'price' => $attributes['options_values_price']
			  );
			  $subindex++;
		    }
	  }
	  $index++;
    }
    $index2++;
 }
 // let's build the email confirmation without html
 $package_num = sizeof($these_products);
 $box_num = $l +1;
 $products_ordered .= 'There will be at least ' . $package_num . ' packages shipped.' . "\n\t";
 for ($l = 0, $m = sizeof($these_products); $l < $m; $l++) {
    $products_ordered .= "\n" . 'Shipment Number ' . $box_num++ . ' ' .
    $these_products[$l]['spacer'] . ' ' .
    $these_products[$l]['Vmodule'] . ' ' .
    $these_products[$l]['spacer'] . ' ' .
    $these_products[$l]['Vmethod'] . ' ' .
    $these_products[$l]['spacer'] . ' ' .
    $these_products[$l]['Vcost'] . "\n\t";
    for ($i = 0, $n = sizeof($these_products[$l]['orders_products']); $i < $n; $i++) {
	  $products_ordered .= "\n\t" .
	  $these_products[$l]['orders_products'][$i]['qty'] . ' x ' . ' ' .
	  $these_products[$l]['orders_products'][$i]['name'] . ' ' .
	  $these_products[$l]['spacer'] . ' ' .
	  $these_products[$l]['orders_products'][$i]['model'] . "\n\t";
	  if (isset ($these_products[$l]['orders_products'][$i]['attributes']) && (sizeof($these_products[$l]['orders_products'][$i]['attributes']) > 0)) {
		    for ($j = 0, $k = sizeof($these_products[$l]['orders_products'][$i]['attributes']); $j < $k; $j++) {
			  $products_ordered .= "\n\t" . 'Options Selected - ' . $these_products[$l]['orders_products'][$i]['attributes'][$j]['option'] . ': ' . $these_products[$l]['orders_products'][$i]['attributes'][$j]['value'];
			  if ($these_products[$l]['orders_products'][$i]['attributes'][$j]['price'] != '0')
				    $products_ordered .= ' (' . $these_products[$l]['orders_products'][$i]['attributes'][$j]['prefix'] . $currencies->format($these_products[$l]['orders_products'][$i]['attributes'][$j]['price'] * $these_products[$l]['orders_products'][$i]['qty'], true, $these_info['currency'], $these_info['currency_value']) . ')' . "\n\t";
		    }
	  }
	  $products_ordered .= "\n\t" . 'Tax ' . tep_display_tax_value($these_products[$l]['orders_products'][$i]['tax']) . '% ' . "\n\t" .
	  'Price Per Item - ' . $currencies->format($these_products[$l]['orders_products'][$i]['final_price'], true, $these_info['currency'], $these_info['currency_value']) . "\n\t" .
	  'Total Without Tax - ' . $currencies->format($these_products[$l]['orders_products'][$i]['final_price'] * $these_products[$l]['orders_products'][$i]['qty'], true, $these_info['currency'], $these_info['currency_value']) . "\n\t" .
	  'Total Including Tax - ' . $currencies->format(tep_add_tax($these_products[$l]['orders_products'][$i]['final_price'], $these_products[$l]['orders_products'][$i]['tax']) * $these_products[$l]['orders_products'][$i]['qty'], true, $these_info['currency'], $these_info['currency_value']) . "\n\t";
    }
 }
?>

Link to comment
Share on other sites

  • 3 weeks later...

Hello

 

I am looking for a multi-vendor shipping module that deals with only flat rate shipping and has the ability to charge for additional items. Here's exactly what I'm looking for:

 

1) Set a different flat rate for each vendor.

 

2) The ability to add an additional item cost to each order

 

3) An automatic override for highest shipping rate. (Example: If a customer orders multiple items from different vendors, then which vendor that has the highest shipping cost will override the others. The additional items will be charged the additional item charge.)

 

Here's a breakdown:

 

1) Vendor #1 5.00

 

2) Vendor #2 7.50

 

3) Vendor #3 10.00

 

That has already been accomplished

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

What if this happens?

 

A customer orders 3 items, 1 from each vendor. I would like for the total shipping cost to be calculated like this:

 

10.00 shipping for the item ordered from Vendor #3. It will be the starting shipping cost because it's the highest

+1.50 additional item ordered from Vendor #1

+1.50 additional item ordered from Vendor #2

____________________________________

13.00 for the total shipping costs

 

I believe that will be a good compromise between the shop owner and the customer on the costs of shipping. However, the shop owner will have the option to take a loss on the shipping costs OR figure a way to make up for the loss in shipping costs.

 

Has this been accomplished? It will take forever to read through 233 pages.

 

Thanks for reading.

Link to comment
Share on other sites

@@kymation

 

Thanks for the very fast response from a busy gentleman. You've implied that #3 can be accomplished with code addition. BUT the same goal may be obtained this way:

 

Charge different shipping rates for different categories, since my products will be arranged by categories not by supplier. Basically, charge a flat shipping rate according to the parent category and all products in the sub-categories will inherit the shipping costs of the parent category.

 

There's already one great attempt to this which I can't get it to work because it's so complex that it's very confusing. That module is Separate Shipping per Product [sSPP].

 

It's easier to apply a flat rate shipping cost to the parent categories and the parent category with the highest shipping costs will be the base while products from other categories with lower shipping costs with be charged the additional item cost.

 

I could use First item X module but one of my suppliers charge a lot more than the rest.

 

What would be your approach to this?

 

Thanks

Link to comment
Share on other sites

My first thought is to modify the First Item Plus module to recognize the category the item is in. You could then add a field to the categories database table taht would contain the First Item price, and maybe another column for the additional item price if that's not the same for all categories.

 

There may be a better way to do this. That was just off the top of my head. I'm finishing up a major project here, so I might put more thought into it later.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

It seems like we're on the same page as far as logic. As for the coding aspect of it, I'm clueless.

 

To clear up exactly what I need:

 

1) Set shipping rates by categories, not by shipping vendor.

 

2) Products listed in sub-categories will inherit the rates of parent categories, unless it's feasible to code an option where sub-categories can have different shipping rates. One supplier has shipping rates ranging from $10 to $50 based on weight. But I will just charge my customers a flat rate close to their averages.

 

3) The highest shipping rate will override the lower rates if items are ordered from different categories with different rates. The items with lower shipping rates will be charged an additional item fee that's previously set no matter which category from which they came.

 

I will PM you for further details.

 

Thanks.

Link to comment
Share on other sites

@@marcochiana

MVS only handles shipping, not ordering. Search the Addons section for Minimum Order -- I believe there is one that you can set minimums by product or manufacturer.

 

@@Roaddoctor

I would love to, but I don't have the time. I have too many things to do as it is. I might do it if someone pays me to, or if I suddenly find myself with a lot of free time.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 4 weeks later...

Hi Jim,

 

I have a osc 2.3.3.4 install and the Vendor Shipping Modules page doesn't show the buttons to add or remove shipping providers. Initially I installed Fedexwebservices and now I cannot disable it. The errors in the log are:

 

[Mon Mar 24 07:06:54 2014] [error] [client 70.16.213.140] PHP Notice: Use of undefined constant FILENAME_STATS_VENDORS - assumed 'FILENAME_STATS_VENDORS' in /home/httpd/vhosts/neperformancemustang.com/httpdocs/catalog/admin/vendors.php on line 542, referer: http://www.neperformancemustang.com/catalog/admin/vendors.php

[Mon Mar 24 07:06:58 2014] [error] [client 70.16.213.140] PHP Notice: Use of undefined constant FILENAME_STATS_VENDORS - assumed 'FILENAME_STATS_VENDORS' in /home/httpd/vhosts/neperformancemustang.com/httpdocs/catalog/admin/vendors.php on line 542, referer: http://www.neperformancemustang.com/catalog/admin/vendors.php?page=1&vendors_id=2

[Mon Mar 24 07:07:00 2014] [error] [client 70.16.213.140] PHP Notice: Undefined variable: check_flag in /home/httpd/vhosts/neperformancemustang.com/httpdocs/catalog/includes/modules/vendors_shipping/bax.php on line 246, referer: http://www.neperformancemustang.com/catalog/admin/vendors.php?page=1&vendors_id=3

[Mon Mar 24 07:07:00 2014] [error] [client 70.16.213.140] PHP Notice: Use of undefined constant MODULE_SHIPPING_AIRBORNE_STATUS - assumed 'MODULE_SHIPPING_AIRBORNE_STATUS' in /home/httpd/vhosts/neperformancemustang.com/httpdocs/catalog/includes/languages/english/modules/vendors_shipping/dhlairborne.php on line 15, referer: http://www.neperformancemustang.com/catalog/admin/vendors.php?page=1&vendors_id=3

[Mon Mar 24 07:07:00 2014] [error] [client 70.16.213.140] PHP Notice: Trying to get property of non-object in /home/httpd/vhosts/neperformancemustang.com/httpdocs/catalog/includes/modules/vendors_shipping/dhlairborne.php on line 50, referer: http://www.neperformancemustang.com/catalog/admin/vendors.php?page=1&vendors_id=3

[Mon Mar 24 07:07:00 2014] [error] [client 70.16.213.140] PHP Notice: Trying to get property of non-object in /home/httpd/vhosts/neperformancemustang.com/httpdocs/catalog/includes/modules/vendors_shipping/fedex1.php on line 41, referer: http://www.neperformancemustang.com/catalog/admin/vendors.php?page=1&vendors_id=3

[Mon Mar 24 07:07:00 2014] [error] [client 70.16.213.140] PHP Notice: Trying to get property of non-object in /home/httpd/vhosts/neperformancemustang.com/httpdocs/catalog/includes/modules/vendors_shipping/fedex1.php on line 42, referer: http://www.neperformancemustang.com/catalog/admin/vendors.php?page=1&vendors_id=3

[Mon Mar 24 07:07:00 2014] [error] [client 70.16.213.140] PHP Fatal error: Call to undefined method fedexwebservices::sort_order() in /home/httpd/vhosts/neperformancemustang.com/httpdocs/catalog/admin/vendor_modules.php on line 141, referer: http://www.neperformancemustang.com/catalog/admin/vendors.php?page=1&vendors_id=3

 

Thanks,

Craig

Link to comment
Share on other sites

Most of those errors are harmless, but the last one is fatal. That one says that your Fedexwebservices module has a coding error. You need to delete that module file and then remove the database entries by hand.

 

Search the vendors_configuration table for any entries containing %fedexwebservices% and delete them. Then look for a configuration_value containing fedexwebservices.php and remove that value.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 4 weeks later...

Hello, I installed it to my 2.3.3 Store and after a bit of hard work everything works now exept one issue: When a customer uses the standard paypal module for payment - then it redirects to checkout_process.php and the confirmation page appears and everything seems workîng. But the order information isn't written in the orders_shipping table.

 

With the other payment methods its working fine. I've already replaced the checkout_process.php file with the clean one, without any modification, the same happened. Is it this file which is corrupt?

 

Does someone have an idea about a solution?

 

Thanks for any respone!

Link to comment
Share on other sites

Are you certain that the Paypal module is using checkout_process.php? I remember it using its own page in place of the stock checkout_process.php. You then have to make the same modifications to the Paypal process page that are made to checkout_process.php.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Are you certain that the Paypal module is using checkout_process.php? I remember it using its own page in place of the stock checkout_process.php. You then have to make the same modifications to the Paypal process page that are made to checkout_process.php.

 

Regards

Jim

 

Thank you, no this wasn't the solving answer. After the payment paypal redirects the customer to checkout_process.php. The paypal module consists of only one file and is integrated in the system...

Link to comment
Share on other sites

In my copy of the stock osCommerce 2.3.3.4 files, in /includes/modules/payment/paypal_standard.php, line 290 is:

 

'notify_url' => tep_href_link('ext/modules/payment/paypal/standard_ipn.php', '', 'SSL', false, false),

 

That looks to me like the notification response from Paypal goes to /ext/modules/payment/paypal/standard_ipn.php, and that file processes the response. I see code in there to update the order status, which would normally be done in checkout_process.php. Since the rest of the database updates that would normally be done by checkout_process.php appear to be in the Paypal Standard module itself, it appears that checkout_process.php is not being used at all.

 

In any case, if you added the MVS code to checkout_process.php, and checkout_process.php is actually being called by Paypal, then the database update is working as intended. Since you say it is not working as intended, the checkout_process.php file is not being called. It's that simple.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

In my copy of the stock osCommerce 2.3.3.4 files, in /includes/modules/payment/paypal_standard.php, line 290 is:

 

'notify_url' => tep_href_link('ext/modules/payment/paypal/standard_ipn.php', '', 'SSL', false, false),

 

That looks to me like the notification response from Paypal goes to /ext/modules/payment/paypal/standard_ipn.php, and that file processes the response. I see code in there to update the order status, which would normally be done in checkout_process.php. Since the rest of the database updates that would normally be done by checkout_process.php appear to be in the Paypal Standard module itself, it appears that checkout_process.php is not being used at all.

 

In any case, if you added the MVS code to checkout_process.php, and checkout_process.php is actually being called by Paypal, then the database update is working as intended. Since you say it is not working as intended, the checkout_process.php file is not being called. It's that simple.

 

Regards

Jim

 

Hi Jim

 

Thank you very much now I know what was wrong. You were right the checkout goes through the standard_ipn.php file. But it seems very different from the checkout_process.php file. Is there just one little code to add or would it be a lot of things I have to think about? Is there already a integration in mvs for the paypal standard module? I didn't found one yet. I'm not very good in php so its a lot of work for me to integrete it. I would be thankfull if you can give me some more hints. Otherwise i will go through some hours of searching in the forums to understand the code and find a solution - probably that would also be good for me to become familliar with all this stuff ;)

standard_ipn.php

Edited by ---luke---
Link to comment
Share on other sites

You have to make the same changes to the Paypal checkout path as you would to the regular osCommerce checkout. That means that all of the MVS code changes in checkout_process.php need to also be made in the Paypal module or the standard_ipn.php file.

 

There is a test that checks whether MVS is enabled in each section. Look for the non-MVS code in those changes and find that in the Paypal files, then make the same changes there. I'll help where I can, but I'm loaded down with paying work right now.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

You have to make the same changes to the Paypal checkout path as you would to the regular osCommerce checkout. That means that all of the MVS code changes in checkout_process.php need to also be made in the Paypal module or the standard_ipn.php file.

 

There is a test that checks whether MVS is enabled in each section. Look for the non-MVS code in those changes and find that in the Paypal files, then make the same changes there. I'll help where I can, but I'm loaded down with paying work right now.

 

Regards

Jim

 

Oke I added the similar code like in checkout_process.php to the standard_ipn.php modul. But after payment some error occured...

 

After that I found a solution for a other paypal ipn module on http://addons.oscommerce.com/info/4129/category,all/search,MVS. Then i had a problem with the price display per item (the shipping costs were too hight). Then I selected an option to only transfer the aggregate amount to paypal. Then everything was working!

 

Anyway I'll say thank you!

 

Regards

lu

Link to comment
Share on other sites

Glad to hear you got it working. Paypal can be a pain to work with sometimes.

 

Regards

Jim

 

Okay now once again i had problems with the order emails and other stuff... Then I went back to the standard paypal module and added some code a member (he's a hero) had posted once (http://www.oscommerce.com/forums/topic/101973-multi-vendor-shipping-new-thread/page__view__findpost__p__1561954) to catalog/includes/modules/payment/paypal_standard.php

 

Now all is working like a charm!

Edited by ---luke---
Link to comment
Share on other sites

@---luke---

Hello, I installed it to my 2.3.3 Store and after a bit of hard work everything works now exept one issue....

Glad to hear that you installed MVS on 2.3.3 too. Naturally it is lot of code integration because of the mighty add-on (thank you all). I plan to go the same route to heaven. Did you had to modify code or 'just add tons of code' according to the instructions? You mentioned that you are not a php expert... I'am not, too. The thread here is well kept and full of helpful information, that makes me optimistic.

 

Regards

Markus

Link to comment
Share on other sites

  • 1 month later...

Hi all, been working on this great contrib for quite a while now.

Has anyone ever needed to tie a specifc vendor_id to a product in an automatic way (that is without selecting from the vendor_id drop down menu in the products page)?

 

If so could anyone point me to the code to look at? My objective is to tie the vendor_id of categories.php to a login_id I'd pull from Admin Access 2.0

Thanks to anybody who could lead me towards the right direction.

Link to comment
Share on other sites

You just need to set the $vendors_id globally. If your Admin Access names are stored in a database table, add a vendors_id column to that, then add some code to pull that value and set $vendors_id -- maybe in the session. Then you may need to modify the vendor-specific Admin pages to get that value at the top of the page, and remove any means of selecting a different value on the page.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...