Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Multi_Vendor_Shipping new thread


blucollarguy

Recommended Posts

Dear Jim,

 

New post, other issue with the orders_by_vendors.php, tried and searched really a lot but with no results (still learning I guess....)

 

Problem description / information:

- There is no data displayed per vendor.

- When the filters are clicked the values for the filters are not set and selected vendor_ID is set to 0.

- OSC version 2.3.4

- MySQL 5.5.36

- PHP Version: 5.3.28

 

What I have done till now (besides Google a lot):

- Tried the file in your link (rar file).

- Changed all to _GET and _POST, no result for both.

- Added code below in application_top:

$HTTP_GET_VARS = $_GET;
$HTTP_POST_VARS = $_POST;
$HTTP_ENV_VARS = $_ENV;
$HTTP_SERVER_VARS = $_SERVER; 
$HTTP_COOKIE_VARS = $_COOKIE; 
$_REQUEST = array_merge($_GET, $_POST, $_COOKIE);

 

- Added code below at the end of the file:

 

print '<pre>';

print '$vendors_id = ' . ($vendors_id) . '<br>';
print '$sent = ' . ($sent) . '<br>';
print '$line_filter = ' . ($line_filter) . '<br>';
print '$status = ' . ($status) . '<br>';
print '$sort_by_filter = ' . ($sort_by_filter) . '<br>';
print '$languages_id = ' . ($languages_id) . '<br>';
print '$vendors_orders_data_query = ';
print_r ($vendors_orders_data_query);
print '<br>';
print '$vendors_orders_data = ';
print_r ($vendors_orders_data);
print '<br>';
print '$vendors_orders = ';
print_r ($vendors_orders);
print '<br>';
print '</pre>';
exit;

 

The result is displayed below when I select a vendor (on opening vendor_id = 0). When I click a filter the vendor_id is set to 0 again.

 

$vendors_id = 1
$sent =
$line_filter = desc
$status =
$sort_by_filter = orders_id
$languages_id = 2
$vendors_orders_data_query = mysqli_result Object
(
[current_field] => 0
[field_count] => 2
[lengths] =>
[num_rows] => 7
[type] => 0
)

$vendors_orders_data =
$vendors_orders =

 

 

Hope you / someone can help me with some directions where to search further (it will probably be the solution for the other problems).

 

Kind Greetings,

 

Fabien

Link to comment
Share on other sites

The code that you added to application_top.php is not needed as it duplicates the compatibility function already found in osCommerce. Adding duplicate code may cause problems as well.
 
$vendors_orders_data being empty indicates to me that the data is not being retrieved by the query. Something is wrong in the query itself. You cannot echo $vendors_orders_data_query as that is the result of the query and not the query itself. You need to change this code
 

$vendors_orders_data_query = tep_db_query("some_query_string");

to something like this

$vendors_orders_data_query_raw = "some_query_string";
$vendors_orders_data_query = tep_db_query($vendors_orders_data_query_raw);

Where some_query_string is the actual database query. Then you can echo $vendors_orders_data_query_raw somewhere below that. Look at the resulting query for empty values of $vendors_id, etc.

 

Regards

Jim

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

Link to comment
Share on other sites

Hi Jim,

 

Thanks for your fast reaction!! I will make sure no duplicate code is in the installation. I did what you asked and still no results but some more information. The first string returns 7 rows and I have checked the DB, with all vendors it displays the correct number of rows. I have added a &$test var to see what happens and the code strands on the while statement (between the $test vars).

 

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

Here is the relevant code.

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

 

//  $index1 = 0;
  if ($sent == 'yes') {
    $vendors_orders_data_query = tep_db_query ("select distinct orders_id, vendor_order_sent from " . TABLE_ORDERS_SHIPPING . " where vendors_id='" . $vendors_id . "' and vendor_order_sent='yes' group by orders_id " . $line_filter . "");
  } elseif ($sent == 'no') {
    $vendors_orders_data_query = tep_db_query ("select distinct orders_id, vendor_order_sent from " . TABLE_ORDERS_SHIPPING . " where vendors_id='" . $vendors_id . "' and vendor_order_sent='no' group by orders_id " . $line_filter . "");
  } else {
$vendors_orders_data_query_raw = "select distinct orders_id, vendor_order_sent from " . TABLE_ORDERS_SHIPPING . " where vendors_id='" . $vendors_id . "' group by orders_id " . $line_filter . "";
    $vendors_orders_data_query = tep_db_query($vendors_orders_data_query_raw);
  }
  $test = 0;
  while ($vendors_orders_data = tep_db_fetch_array ($vendors_orders_data_query)) {
   $test = $test++;
    if (isset ($status)) {
      $orders_query = tep_db_query ("select distinct o.customers_id, o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from (" . TABLE_ORDERS . " o) left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = '" . $status . "' and o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "' and ot.class = 'ot_total' and o.orders_id =  '" . $vendors_orders_data['orders_id'] . "' order by o." . $sort_by_filter . " ASC");
    } else {
 
      $orders_query = tep_db_query ("select distinct o.customers_id, o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from (" . TABLE_ORDERS . " o) left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "' and ot.class = 'ot_total' and o.orders_id =  '" . $vendors_orders_data['orders_id'] . "' order by o." . $sort_by_filter . " ASC");
    }
    while ($vendors_orders = tep_db_fetch_array ($orders_query) ) {
      $date_purchased = $vendors_orders['date_purchased'];

 

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

Code to view the vars:

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

print '<pre>';
print '$test = ' . ($test) . '<br>';
print '$vendors_id = ' . ($vendors_id) . '<br>';
print '$sent = ' . ($sent) . '<br>';
print '$line_filter = ' . ($line_filter) . '<br>';
print '$status = ' . ($status) . '<br>';
print '$sort_by_filter = ' . ($sort_by_filter) . '<br>';
print '$languages_id = ' . ($languages_id) . '<br>';
 
print '$vendors_orders_data_query_raw = ';
print_r ($vendors_orders_data_query_raw);
print '<br>';
 
print '$vendors_orders_data_query = ';
print_r ($vendors_orders_data_query);
print '<br>';
 
print '$vendors_orders_data = ';
print_r ($vendors_orders_data);
print '<br>';
 
print '$vendors_orders = ';
print_r ($vendors_orders);
print '<br>';
 
print '</pre>';
exit;
 
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Result on the page:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$test = 0
$vendors_id = 6
$sent =
$line_filter = desc
$status =
$sort_by_filter = orders_id
$languages_id = 2
$vendors_orders_data_query_raw = select distinct orders_id, vendor_order_sent from orders_shipping where vendors_id='6' group by orders_id desc
$vendors_orders_data_query = mysqli_result Object
(
[current_field] => 0
[field_count] => 2
[lengths] =>
[num_rows] => 7
[type] => 0
)

$vendors_orders_data =
$vendors_orders = 
 
 
I hope this make sense??
 
Kind greetings,
 
Fabien
Link to comment
Share on other sites

You have three different values for $vendors_orders_data_query in an if/elseif/else statement, but you only converted the last of those. How do you know that is the one being executed? It looks like it is, but you should never assume that.

 

You got the following query back:

select distinct orders_id, vendor_order_sent from orders_shipping where vendors_id='6' group by orders_id desc

Now go plug that into your database and see how many rows you get back. If it's zero, look at why it is not returning any data. Are there database fields that meet that criteria? If not, your data is not being saved to the database.

 

Regards

Jim

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

Link to comment
Share on other sites

Hi Jim,

 

In the previous post the output showed that there where seven rows of data (that made me sure I was modding the right query ;-).

 

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

I ran the SQL statement on my DB:

 

select distinct orders_id, vendor_order_sent from " . TABLE_ORDERS_SHIPPING . " where vendors_id='" . $vendors_id . "' group by orders_id " . $line_filter . ""

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

 

Result is seven rows:

 

orders_id   vendor_order_sent

33              no
32              yes
31              no
28              yes
27              no
26              yes
25              no
 
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Can it have something to do that during the creation I had a SQL error by creating this table (due to the SQL version)?
I searched the forum and found that you have to replace TYPE to ENGINE and it worked and works for the rest of MVS.
 
CREATE TABLE `orders_shipping` (
  `orders_shipping_id` int(11) NOT NULL auto_increment,
  `orders_id` int(11) NOT NULL default '0',
  `vendors_id` int(11) NOT NULL default '1',
  `shipping_module` varchar(16) NOT NULL default '',
  `shipping_method` varchar(128) NOT NULL default '',
  `shipping_cost` decimal(15,4) NOT NULL default '0.000',
  `shipping_tax` decimal(15,4) NOT NULL default '0.000',
  `vendors_name` varchar(64) NOT NULL default '',
  `vendor_order_sent` varchar(3) NOT NULL default 'no',
  PRIMARY KEY  (`orders_shipping_id`)
) ENGINE=MyISAM AUTO_INCREMENT=0 ;
 
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Database information table orders_shipping
 
Type     Collation                           Attributes          Empty                    Default      Extra           Action
1           orders_shipping_id          int(11)                                                               No              No                 AUTO_INCREMENT
2           orders_id                         int(11)                                                               No              0
3           vendors_id                       int(11)                                                               No              1
4           shipping_module             varchar(16)       utf8_unicode_ci                       No
5           shipping_method             varchar(128)     utf8_unicode_ci                       No
6           shipping_cost                  decimal(15,4)                                                    No              0.0000
7           shipping_tax                    decimal(15,4)                                                    No              0.0000
8           vendors_name                varchar(64)       utf8_unicode_ci                       No
9           vendor_order_sent         varchar(3)          utf8_unicode_ci                       No              no
 
Thanks Jim I am learning each day!
 
P.s. on my live shop which runs osc 2.2 and SQL 5.x this page doesn't work as well (I guess after my provider upgraded to SQL an PHP 5+) 
 
 
Kind greetings,
 
Fabien
Edited by Peace2u
Link to comment
Share on other sites

It looks like that query is OK. Keep going down the page and inserting print() statements where appropriate. There is still something on that page that is not working.

 

Regards

Jim

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

Link to comment
Share on other sites

Hi Jim,

 

Got the page orders_per_vendor working, there where problems in my installation with:

 

_GET and _POST
The _GET function works when the values are set via a href link and the _POST works when a pull down is used.
After adding both for $vendors_id and &status the filters work (probably a dirty solution....) .

 

$vendors_id = 1;
  
    if (isset ($_POST['vendors_id'])) {
    $vendors_id = (int) $_POST['vendors_id'];
  }  
  
  if (isset ($_GET['vendors_id'])) {
    $vendors_id = (int) $_GET['vendors_id'];
  }
  
  $line_filter = 'desc';
  if (isset ($_GET['line']) && $_GET['line'] == 'asc') {
    $line_filter = $_GET['line'];
  }
 
  $sort_by_filter = 'orders_id';
  if (isset ($_GET['by']) && $_GET['by'] != '') {
    switch ($_GET['by']) {
      case 'date':
        $sort_by_filter = 'date_purchased';
        break;
      case 'customer':
        $sort_by_filter = 'customers_id';
        break;
      case 'status':
        $sort_by_filter = 'status';
        break;
      case 'sent':
        $sort_by_filter = 'sent';
        break;
      default:
        $sort_by_filter = 'orders_id';
        break;
    }
  }
    
  $status = '';
  if (isset ($_POST['status']) && $_POST['status'] != '') {
  $status = $_POST['status'];
    $status = preg_replace("(\r\n|\n|\r)", '', $status); // Remove CR &/ LF
    $status = preg_replace("/[^A-Za-z0-9]/i", '', $status); // strip everthing except alphanumerics
  }
  
  if (isset ($_GET['status']) && $_GET['status'] != '') {
  $status = $_GET['status'];
$status = preg_replace("(\r\n|\n|\r)", '', $status); // Remove CR &/ LF
    $status = preg_replace("/[^A-Za-z0-9]/i", '', $status); // strip everthing except alphanumerics
  }
 
  $sent = '';
  if (isset ($_GET['sent']) && ($_GET['sent'] == 'yes' || $_GET['sent'] == 'no') ) {
    $sent = $_GET['sent'];
  }
 
 
Setting vars at the section for the Mail filter
Added  . '&status=' . $status to:
<td class="main" align="left"><?php echo 'Filter by email sent: <a href="' . tep_href_link(FILENAME_ORDERS_VENDORS, '&vendors_id=' . $vendors_id . '&line=' . $line_filter . '&status=' . $status . '&sent=yes') . '"><b>YES</a></b>  <a href="' . tep_href_link(FILENAME_ORDERS_VENDORS, '&vendors_id=' . $vendors_id . '&line=' . $line_filter . '&status=' . $status . '&sent=no') . '"><b>NO</a></b>'; ?></td>
 
 
Setting vars at the section for Ascending en desending
Added & before vendors_id=' . $vendors_id
 
<?php
  if ($line_filter == 'asc') {
    if ($status > 0) {
?>
                <td class="main" align="right"><?php echo 'Change to <a href="' . tep_href_link (FILENAME_ORDERS_VENDORS, '&vendors_id=' . $vendors_id . '&line=desc' . '&sent=' . $sent . '&status=' . $status) . '"><b>DESCENDING</a></b> order'; ?></td>
<?php
    } else {      
?>
                <td class="main" align="right"><?php echo 'Change to <a href="' . tep_href_link (FILENAME_ORDERS_VENDORS, '&vendors_id=' . $vendors_id . '&line=desc' . '&sent=' . $sent) . '"><b>DESCENDING</a></b> order'; ?></td>
<?php
    } 
 
 
Setting vars at the section for status
Added sent var to section below
 
<td class="main" align="right"><?php echo tep_draw_form('status_report', FILENAME_ORDERS_VENDORS . '?&vendors_id=' . $vendors_id . '?&sent=' . $sent)  . HEADING_TITLE_STATUS        . ' '; ?><?php echo tep_draw_pull_down_menu('status', $orders_statuses, '','onChange="this.form.submit()";');?></form></td>
 
 
Problem with Isset
Changed the code:        if (isset ($status)) {
To:                                 if ($status > 0) {
 
 
Thanks for your help and if there is a better solution possible I will be glad to hear this (finding the hick-up is one, learning the best solution the other).
Hope this helps some one else, on with the next page!
 
Kind greetings,
 
Fabien
Edited by Peace2u
Link to comment
Share on other sites

  • 1 month later...

Hey Jim..

 

I got it working.. sort of..

 

Question: is there a method for upgrading the UPSXML to the latest? Can't seem to get past this error.. 

 PHP Fatal error:  Call to undefined method upsxml::sort_order() in /var/www/vhosts/osc-mvs/public_html/admin/vendor_modules.php on line 122, referer: http://osc-mvs.dev/admin/vendors.php?page=1&vendors_id=3

It still returns rates the options are different on the admin side.. 

Link to comment
Share on other sites

All of the sites I maintain are still using the old UPSXML module without any errors. I think there's still something wrong with your Order by Vendor file.

 

If you want to, you can take the current UPSXML file and modify it for MVS. I would just do a compare with the modified version in the MVS package. All the changes are marked.

 

Regards

Jim

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

Link to comment
Share on other sites

Hey Jim,

 

That's where I get the sort error above which I only gave half-hearted attempt towards debugging with the new module inside MVS.. 

 

Call to undefined method upsxml::sort_order() 

 

But you answered my concerns anyway, and if it's working I'll stick with the old one for now..  thanks

Edited by opus_uno2001
Link to comment
Share on other sites

  • 3 weeks later...

I use this contribution and love it.

 

I am not a programmer and have no clue on how to do what I want.

 

I would like to add a button to the customer order in admin that would allow me to view the vendor order email and print it.  This would stream line from having to go back to the vendor orders to see the email.  Any help is greatly appreciated.

Link to comment
Share on other sites

  • 1 month later...

Will this module combine shipping instead of seperating? What I want is a shipping option that combines all the shipping cost or this can't be done? For example one of my suppliers is based on total price other by weight and I like to combine them as lets say just say Shipping Cost $

Link to comment
Share on other sites

It can't be done. The osCommerce shipping modules all return different options. If one vendor uses USPS with six optional shipping methods, and one uses UPS with five, and one uses a single flat rate, how do you combine that?

 

Regards

Jim

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

Link to comment
Share on other sites

That tells me that you don't have any shipping modules installed. Go into your store's Admin and add at least one shipping module to the default vendor. See the instructions for how to do this.

 

Regards

Jim

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

Link to comment
Share on other sites

Thanks Jim,

 

I was wondering if this is possible to put the mvs in a seperate file container for example in checkout process use something like this:

include('includes/vendors_checkout_process.php');

That way when oscommerce gets updated it will be less of a hassle. Like seperate modules or this can't be done. That's the problem with oscommerce you have to change the core instead of modules like some other carts do. Thank you for your time

Link to comment
Share on other sites

MVS is very old code -- it was originally coded for osC 2.2MS2. It would certainly be possible to use more class structure and modules to make less of an impact on the core code. I don't know if there will ever be enough hooks to make it completely free of core code changes, but it can certainly be improved from where it is now.

 

Of course, this would mean that I have to spend a lot of time updating the code, or that somebody else would have to take over some (or all) of the work. I suspect there is little chance of either.

 

Regards

Jim

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

Link to comment
Share on other sites

Thanks Jim, yeah I have been working out some of the old code like ereg stuff like that. I am new to Php and this has been a challenge. I looked in other carts and oscommerce is the only one that has this feature without spending a ton of money like cs-cart. Opencart has vendor capability but a ton of money to add modules to it. I like the idea of opencart using modules instead of changing the core of the cart as it should be.

 

ereg gets replaced with preg correct?

 

this line:

 

if (ereg('->', $use_function)) {

 

be

 

if (preg('->', $use_function)) {

Edited by drillsar
Link to comment
Share on other sites

Almost. Preg need delimiters, like this:

if (preg('{->}', $use_function)) {

I used {} as delimiters in this case, but they can be any character that does not appear in the expression.

 

Regards

Jim

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

Link to comment
Share on other sites

ok I am getting there I think lol:

 

I getting this error now

 

Warning: Invalid argument supplied for foreach() in /home/giftboun/public_html/checkout_process.php on line 153

Warning: Cannot modify header information - headers already sent by (output started at /home/giftboun/public_html/checkout_process.php:153) in /home/giftboun/public_html/includes/functions/general.php on line 49

 

Also when I go to checkout payment it reads Please select a payment method for your order. In Red before even I click on anything

Link to comment
Share on other sites

I don't know what's on Line 153 of checkout_process.php, but it's trying to loop on an array that's not being set. You need to look at what's supposed to be generating that array and track it down. The second error is caused by the first, and the third may be related. Fix the first one and then see what happens.

 

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