Jump to content
blucollarguy

Multi_Vendor_Shipping new thread

Recommended Posts

Ok one thing at a time, lol

 

in vendor_modules.php

 

Line 27 I replaced

 

$value = ereg_replace (", --none--", "", $value);

 

with:

$value = preg_replace (", --none--", "", $value);

 

Also Line 229 replaced

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

 

with:

 

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

 

still getting this error:

 

 

Fatal error: Call to undefined function preg() in vendor_modules.php on line 229

Share this post


Link to post
Share on other sites

All regex functions need delimiters. That first one should be:

$value = preg_replace ("{, --none--}", "", $value);

Actually it's silly to use a regex for that, so it really should be:

$value = str_replace (", --none--", "", $value);

I missed that second one. Caught the missing delimiters and completely missed the function itself. It should be:

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

Regards

Jim


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

Share this post


Link to post
Share on other sites

Ok that did the trick thanks.. Now I am trying to solve this error:

 

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

 

This happen when Enable Vendor Shipping is false... hmmm

//MVS start
// Insert data into new orders_shipping table
  $shipping_array = $shipping['vendor'];
  foreach ($shipping_array as $vendors_id => $shipping_data) {
    $vendors_query = tep_db_query ("select vendors_name
                                    from " . TABLE_VENDORS . "
                                    where vendors_id = '" . (int)$vendors_id . "'"
                                  );
    $vendors_name = 'Unknown';
    if ($vendors = tep_db_fetch_array($vendors_query)) {
      $vendors_name = $vendors['vendors_name'];
    }
    $shipping_method_array = explode ('_', $shipping_data['id']);
    // Fix the shipper name where needed
    switch ($shipping_method_array[0]) {
      case 'fedex1':
        $shipping_method = 'Federal Express';
      case 'upsxml':
      case 'UPSXML':
      case 'ups':
        $shipping_method = 'UPS';
      case 'usps':
        $shipping_method = 'USPS';
      default:
        $shipping_method = $shipping_method_array[0];
    } //switch

    $sql_data_array = array ('orders_id' => $orders_id,
                             'vendors_id' => $vendors_id,
                             'shipping_module' => $shipping_method,
                             'shipping_method' => $shipping_data['title'],
                             'shipping_cost' => $shipping_data['cost'],
                             'shipping_tax' =>  $shipping_data['ship_tax'],
                             'vendors_name' => $vendors_name,
                             'vendor_order_sent' => 'no'
                            );
    tep_db_perform (TABLE_ORDERS_SHIPPING, $sql_data_array);
  } //foreach ($shipping_array
//MVS End
Edited by drillsar

Share this post


Link to post
Share on other sites

When Enable Vendor Shipping is True:

 

This is what error I get

 

Warning: strpos() expects parameter 1 to be string, array given in vendor_shipping.php on line 46

Warning: strpos() expects parameter 1 to be string, array given in includes/modules/order_total/ot_shipping.php on line 48

Warning: substr() expects parameter 1 to be string, array given in includes/modules/order_total/ot_shipping.php on line 48

 

Ok let me try and look at all the coding again.. one by one

Share this post


Link to post
Share on other sites

Ok I think I have it almost complete to 2.3.4. The only problem is when I go to checkout it complains that of this error before I even select anything during the payment screen:

 

Please select a payment method for your order.

 

It's minor but annoying, lol.

 

my site is located at http://giftbound.6srv.com

Edited by drillsar

Share this post


Link to post
Share on other sites

I've seen that before, but I don't think I ever found the cause. That warning is only supposed to show the second time the page displays, which would be after an error happened the first time. I don't remember what triggers the warning. I'll try to take a look later if I have the time.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Here is one issue that I just seen if you enable vendor shipping to false you get this error:

 

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

 

I am thinking that you need to add if vendor_shipping is true or something. I am looking into this issue

//MVS start
// Insert data into new orders_shipping table
  $shipping_array = $shipping['vendor'];
  foreach ($shipping_array as $vendors_id => $shipping_data) {
    $vendors_query = tep_db_query ("select vendors_name
                                    from " . TABLE_VENDORS . "
                                    where vendors_id = '" . (int)$vendors_id . "'"
                                  );

Share this post


Link to post
Share on other sites

Yes, MVS does not behave well if you switch it off. That almost never happens, though, so we never had a good reason to fix it. As you said, just wrap that code in an if that checks SELECT_VENDOR_SHIPPING.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Thanks Jim, that is fixed. Most people will want the MVS though so no big deal. I am looking into this stupid error on checkout_payment screen. This line I believe is the problem:

 

in checkout_confirmation.php this line looks ok I think:

if ( ($payment_modules->selected_module != $payment) || ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
  }

  if (is_array($payment_modules->modules)) {
    $payment_modules->pre_confirmation_check();
  }

Share this post


Link to post
Share on other sites

That looks OK to me. The problem is most likely in the top of checkout_payment.php, although it could be in a function or class somewhere. The  osC checkout process is complex.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Is it a possible bug in oscommerce itself? I looked in payment.php and uses javascript to check fields. I am wondering maybe that is the problem. Still investigating this issue; I look into this further tnt. Thanks for all your help

Share this post


Link to post
Share on other sites

Ok without MVS mod their is no error so it has to be the MVS code that is releasing the error. I will look more into this tnt.

 

is their away to debug it like print to the screen on the process? Or maybe it be better if I upload each section one at a time to see where the error is coming from.

Edited by drillsar

Share this post


Link to post
Share on other sites

Ok I just uploaded one file to the catalog directory. It seems the checkout_shipping.php is the problem file. I will look at the code and see if I can figure it out.

Share this post


Link to post
Share on other sites

I am wondering if this is correct?

 

in checkout_shipping.php

if ( (isset($quote[0]['methods'][0]['title']) ) && (isset($quote[0]['methods'][0]['cost'])) ) {
                $shipping = array('id' => $shipping,
                                  'title' => ( ($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                                  'cost' => $quote[0]['methods'][0]['cost']);

                tep_redirect (tep_href_link (FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL') );
              }

shouldn't that be tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

Share this post


Link to post
Share on other sites

That is part of the stock osCommerce code. It's supposed to skip the Checkout Shipping page if none of the products would have a shipping charge (virtual products/free shipping).

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

I think that was it.. No error on my side. since where on this file my question is are we supposed to take out on checkout_shipping.php

} else {
      if ( defined('SHIPPING_ALLOW_UNDEFINED_ZONES') && (SHIPPING_ALLOW_UNDEFINED_ZONES == 'False') ) {
        tep_session_unregister('shipping');

There is 2 refrences on this in checkout_shipping.php where the MVS code is at it's taken out so I was wondering if that needs to be out.

 

Here is the MVS code:

// MVS Start
      if (SELECT_VENDOR_SHIPPING == 'true') {
        $total_shipping_cost = 0;
        $shipping_title = MULTIPLE_SHIP_METHODS_TITLE;
        $vendor_shipping = $cart->vendor_shipping;
        $shipping = array();

        foreach ($vendor_shipping as $vendor_id => $vendor_data) {
          $products_shipped = $_POST['products_' . $vendor_id];
          $products_array = explode ("_", $products_shipped);

          $shipping_data = $_POST['shipping_' . $vendor_id];
          $shipping_array = explode ("_", $shipping_data);
          $module = $shipping_array[0];
          $method = $shipping_array[1];
          $ship_tax = $shipping_array[2];

          if ( is_object($$module) || ($module == 'free') ) {
            if ($module == 'free') {
              $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
              $quote[0]['methods'][0]['cost'] = '0';
            } else {
              $total_weight = $vendor_shipping[$vendor_id]['weight'];
              $shipping_weight = $total_weight;
              $cost = $vendor_shipping[$vendor_id]['cost'];
              $total_count = $vendor_shipping[$vendor_id]['qty'];
              $quote = $shipping_modules->quote($method, $module, $vendor_id);

            }
            if (isset($quote['error'])) {
              tep_session_unregister('shipping');
            } else {
              if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
                $output[$vendor_id] = array('id' => $module . '_' . $method,
                                            'title' => $quote[0]['methods'][0]['title'],
                                            'ship_tax' => $ship_tax,
                                            'products' => $products_array,
                                            'cost' => $quote[0]['methods'][0]['cost']
                                           );
                $total_ship_tax += $ship_tax;
                $total_shipping_cost += $quote[0]['methods'][0]['cost'];
              }//if isset
            }//if isset
          }//if is_object
        }//foreach
        if ($free_shipping == true) {
          $shipping_title = $quote[0]['module'];
        } elseif (count($output) <2) {
          $shipping_title = $quote[0]['methods'][0]['title'];
        }
        $shipping = array('id' => $shipping,
                          'title' => $shipping_title,
                          'cost' => $total_shipping_cost,
                          'shipping_tax_total' => $total_ship_tax,
                          'vendor' => $output
                         );

        tep_redirect (tep_href_link (FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL') );

      } else {
// MVS End
      if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
        if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) {
          $shipping = $HTTP_POST_VARS['shipping'];

          list($module, $method) = explode('_', $shipping);
          if ( is_object($$module) || ($shipping == 'free_free') ) {
            if ($shipping == 'free_free') {
              $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
              $quote[0]['methods'][0]['cost'] = '0';
            } else {
              $quote = $shipping_modules->quote($method, $module);
            }
            if (isset ($quote['error']) ) {
              tep_session_unregister('shipping');
            } else {
              if ( (isset($quote[0]['methods'][0]['title']) ) && (isset($quote[0]['methods'][0]['cost'])) ) {
                $shipping = array('id' => $shipping,
                                  'title' => ( ($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                                  'cost' => $quote[0]['methods'][0]['cost']);

                tep_redirect (tep_href_link (FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL') );
              }
            }
          } else {
            tep_session_unregister ('shipping');
          }
        } else {
          tep_session_unregister('shipping');
        }
      } else {
      $shipping = false;
      
// MVS
      }
      
     //tep_redirect (tep_href_link (FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL') );
  }

here is what in question if this needs to be indeed out

  }
    } else {
      if ( defined('SHIPPING_ALLOW_UNDEFINED_ZONES') && (SHIPPING_ALLOW_UNDEFINED_ZONES == 'False') ) {
        tep_session_unregister('shipping');

There is also another reference of this in the new checkout_shipping.php

 if ( defined('SHIPPING_ALLOW_UNDEFINED_ZONES') && (SHIPPING_ALLOW_UNDEFINED_ZONES == 'False') && !tep_session_is_registered('shipping') && ($shipping == false) ) {
    $messageStack->add_session('checkout_address', ERROR_NO_SHIPPING_AVAILABLE_TO_SHIPPING_ADDRESS);

    tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL'));
  }

Share this post


Link to post
Share on other sites

Jim,

 

when I changed the code

tep_redirect (tep_href_link (FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL') );

to

tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

the error is indeed gone

Share this post


Link to post
Share on other sites

Whatever works for you. That code should not even execute as it is an alternative section to MVS code. Oh well.

 

For you previous question, that is new code in osCommerce 2.3.4. It needs to stay in. It should go before the MVS code block, in a section that is always executed.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

it has to be here in checkout_shipping.php I believe because that error showed up and that was the only file I uploaded at the time.

Share this post


Link to post
Share on other sites

I added this and now I get a blank page, I commented it //this i added

// MVS Start
      if (SELECT_VENDOR_SHIPPING == 'true') {
        $total_shipping_cost = 0;
        $shipping_title = MULTIPLE_SHIP_METHODS_TITLE;
        $vendor_shipping = $cart->vendor_shipping;
        $shipping = array();

        foreach ($vendor_shipping as $vendor_id => $vendor_data) {
          $products_shipped = $_POST['products_' . $vendor_id];
          $products_array = explode ("_", $products_shipped);

          $shipping_data = $_POST['shipping_' . $vendor_id];
          $shipping_array = explode ("_", $shipping_data);
          $module = $shipping_array[0];
          $method = $shipping_array[1];
          $ship_tax = $shipping_array[2];

          if ( is_object($$module) || ($module == 'free') ) {
            if ($module == 'free') {
              $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
              $quote[0]['methods'][0]['cost'] = '0';
            } else {
              $total_weight = $vendor_shipping[$vendor_id]['weight'];
              $shipping_weight = $total_weight;
              $cost = $vendor_shipping[$vendor_id]['cost'];
              $total_count = $vendor_shipping[$vendor_id]['qty'];
              $quote = $shipping_modules->quote($method, $module, $vendor_id);

            }
            if (isset($quote['error'])) {
              tep_session_unregister('shipping');
            } else {
              if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
                $output[$vendor_id] = array('id' => $module . '_' . $method,
                                            'title' => $quote[0]['methods'][0]['title'],
                                            'ship_tax' => $ship_tax,
                                            'products' => $products_array,
                                            'cost' => $quote[0]['methods'][0]['cost']
                                           );
                $total_ship_tax += $ship_tax;
                $total_shipping_cost += $quote[0]['methods'][0]['cost'];
              }//if isset
            }//if isset
          }//if is_object
        }//foreach
        if ($free_shipping == true) {
          $shipping_title = $quote[0]['module'];
        } elseif (count($output) <2) {
          $shipping_title = $quote[0]['methods'][0]['title'];
        }
        $shipping = array('id' => $shipping,
                          'title' => $shipping_title,
                          'cost' => $total_shipping_cost,
                          'shipping_tax_total' => $total_ship_tax,
                          'vendor' => $output
                         );

        tep_redirect (tep_href_link (FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL') );

      } else {
// MVS End
      if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
        if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) {
          $shipping = $HTTP_POST_VARS['shipping'];

          list($module, $method) = explode('_', $shipping);
          if ( is_object($$module) || ($shipping == 'free_free') ) {
            if ($shipping == 'free_free') {
              $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
              $quote[0]['methods'][0]['cost'] = '0';
            } else {
              $quote = $shipping_modules->quote($method, $module);
            }
            if (isset ($quote['error']) ) {
              tep_session_unregister('shipping');
            } else {
              if ( (isset($quote[0]['methods'][0]['title']) ) && (isset($quote[0]['methods'][0]['cost'])) ) {
                $shipping = array('id' => $shipping,
                                  'title' => ( ($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                                  'cost' => $quote[0]['methods'][0]['cost']);

                tep_redirect (tep_href_link (FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL') );
              }
            }
// This I added         
        } else {
          tep_session_unregister('shipping');
        }
      }
    } else {
      if ( defined('SHIPPING_ALLOW_UNDEFINED_ZONES') && (SHIPPING_ALLOW_UNDEFINED_ZONES == 'False') ) {
        tep_session_unregister('shipping');
      } else {
      $shipping = false;
      
// MVS
      }
      
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
    }    
  }

Share this post


Link to post
Share on other sites

A blank page means an error. Turn on error reporting in includes/application_top.php to see what the error is.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

yeah I have this in application_top.php

 

// set the level of error reporting
  error_reporting(E_ALL);

 

 

but no errors are being printed..

Share this post


Link to post
Share on other sites

I am moving to another hosting company. I will do more of this tnt. I hope to fix that payment error tnt and done with it lol. Thanks Jim.

Share this post


Link to post
Share on other sites

here is another question. How do I change the button's in product_ship_estimator? I perhaps want to add button's as well here

 

I like to change the buttons to correspond with oscommerce look. I see the following code on the buttons I want to change but no clue on how this is done..

 

for example this don't show change_address as a button

<div width="100%" align="center">
        <?php echo tep_draw_button(IMAGE_BUTTON_CHANGE_ADDRESS, 'triangle-1-e', tep_href_link(FILENAME_PRODUCTS_SHIP_ESTIMATOR, 'action=reset&pid=' . $products_id, 'SSL')); ?>

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

×