Jump to content
Latest News: (loading..)
ednique

[Contribution] Ship In Cart

Recommended Posts

Hello Greg @@BlueBunyip,

 

Please try for now to define all countries for the most expensive shipping zone. I'll try to find a generic fix for all configurations.

 

Please, which version do you use which is working correct on your store??

 

Thank you and kind regards

Rainer

Share this post


Link to post
Share on other sites

Hello Greg @@BlueBunyip,

 

I believe I found the error. If you could try:

The Variables “$cart_country_id, $cart_zone” were missing in the globals list.

Please replace line 55 in includes/modules/content/cart/cm_cart_shipping_estimator.php:

      global $oscTemplate, $currencies, $request_type, $cart, $order, $total_count, $method, $module, $shipping, $navigation, $cart_country_id, $cart_zone;

Let me know if it's solved, so I can upload the fix.

 

Thank you and kind regards

Rainer

Share this post


Link to post
Share on other sites

Hello Greg @@BlueBunyip,

 

I believe I found the error. If you could try:

The Variables “$cart_country_id, $cart_zone” were missing in the globals list.

Please replace line 55 in includes/modules/content/cart/cm_cart_shipping_estimator.php:

      global $oscTemplate, $currencies, $request_type, $cart, $order, $total_count, $method, $module, $shipping, $navigation, $cart_country_id, $cart_zone;

Let me know if it's solved, so I can upload the fix.

 

Thank you and kind regards

Rainer

Hi Rainer,

 

you also need to add $total_weight to the globals - otherwise the shipment weight is not passed to shipping modules that need the weight. Once this is done it all looks good for me now.

 

 

Great work

 

 

Greg

Share this post


Link to post
Share on other sites

@@raiwa

 

Hi Rainer

 

In addition to what Greg mentioned above you also need to add $language into the globals otherwise you get a "file not found" error when you reach free shipping.

Share this post


Link to post
Share on other sites

@@vampirehunter,

 

See here:

http://forums.oscommerce.com/topic/396632-shipping-quote-in-cart-2334-support-thread/?p=1707594

 

Tsimi's, as I could see by screenshot and code, doesn't use registered customer addresses when logged in. It's only country-state based.

And it's modal pop up.

Ship in cart is a fixed module added at the bottom of the shopping cart page.

Share this post


Link to post
Share on other sites

My version, that sounds so stupid since i didn't code it. I just packed it inside a modal nothing more. Credits should go to Matt and the Roaddoctor.

Anyway, "my" version does not support what Raiwa said and also it doesn't support Discount Codes 3.2

In the link Raiwa posted you can read that later on the De Dokta took my idea of the modal and perfected it adding some ajax to it and also the whole login recognition stuff. I use some special shipping modules that wouldn't work with any estimator as they stand now so De Dokta was so kind to help me out in this matter.

Share this post


Link to post
Share on other sites

@@raiwa

Hi Rainer,

 

great work!

if customers are not loged in then would be great to define zone_id in $order->delivery

Example from order class:

      $this->delivery = array('firstname' => $shipping_address['entry_firstname'],
                              'lastname' => $shipping_address['entry_lastname'],
                              'company' => $shipping_address['entry_company'],
                              'street_address' => $shipping_address['entry_street_address'],
                              'suburb' => $shipping_address['entry_suburb'],
                              'city' => $shipping_address['entry_city'],
                              'postcode' => $shipping_address['entry_postcode'],
                              'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']),
                              'zone_id' => $shipping_address['entry_zone_id'], //its critical
                              'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']),
                              'country_id' => $shipping_address['entry_country_id'],
                              'format_id' => $shipping_address['address_format_id']);

My solution with STORE_ZONE:
 

		      	$order->delivery = array( 'postcode' => $cart_zip_code,
		                                  'country' => array('id' => $cart_country_id, 
                                                          'title' => $country_info['countries_name'], 
                                                          'iso_code_2' => $country_info['countries_iso_code_2'], 
                                                          'iso_code_3' =>  $country_info['countries_iso_code_3']),
                                      'country_id' => $cart_country_id,
		                                  'format_id' => tep_get_address_format_id($cart_country_id),
                                      'zone_id' => STORE_ZONE);

Thanks!


:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Share this post


Link to post
Share on other sites

@@raiwa

 

Do you, or anyone else, have this working in a store that has a SSL certificate installed?

 

http://forums.oscommerce.com/topic/396632-shipping-quote-in-cart-2334-support-thread/?p=1731213

 

Malcolm


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Frozen" release here

Share this post


Link to post
Share on other sites

Hello @@ArtcoInc,

 

To which add-on do you refer??

The forum you mention is about Tsimi's version which is another add-on.

 

My add-on "ship in cart" and for which this thread is:

http://addons.oscommerce.com/info/9066

 

I tested it myself with SSL only on my local dev installation under windows and XAMPP.

On my live store it's running without SSL.

But I didn't get any complaints until now, it should run under SSL.

 

regards

Rainer

Share this post


Link to post
Share on other sites

@@raiwa

 

No, I am using Tsimi's version, which is based on Roaddoctor's version. I was just checking to see if you know of any problems with using an estimator on a site with a SSL certificate.

 

Thank you, though!

 

Malcolm


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Frozen" release here

Share this post


Link to post
Share on other sites

Thank you.

 

Malcolm


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Frozen" release here

Share this post


Link to post
Share on other sites

@@raiwa

 

I installed your latest upload on version 2.3.3.4BS and it works perfectly when logged in. However, for a prospective customer, when selecting a different shipping method or updating the page the shipping methods disappear.

 

I could send you a copy of my shopping cart page for you to test or you could send me a test copy with shipping estimator code so I could test. Also, I have a custom coded shipping module which is flat rate. With that shipping module, I'm able to set shipping different rates per product.

 

Thanks

Edited by discxpress

Share this post


Link to post
Share on other sites

Hello @@discxpress,

 

Could you check first if the shipping estimator module works correct without your custom shipping module.

If it works correct, then try to check if your custom shipping module uses additional variables which should may be added to the globals list in the shipping estimator module line 58.

 

regards

Rainer

Edited by raiwa

Share this post


Link to post
Share on other sites

Hello @@discxpress,

 

Could you check first if the shipping estimator module works correct without your custom shipping module.

If it works correct, then try to check if your custom shipping module uses additional variables which should may be added to the globals list in the shipping estimator module line 58.

 

regards

Rainer

Thanks for the reply. Tell me how to locate those variables in the custom shipping module. Or what would those variables look like?

 

I appreciate your help

Share this post


Link to post
Share on other sites
<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2008 osCommerce

  Released under the GNU General Public License
*/

  class multi {
    var $code, $title, $description, $icon, $enabled;

// class constructor
    function multi() {
      global $order;

      $this->code = 'multi';
      $this->title = MODULE_SHIPPING_MULTI_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_MULTI_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_MULTI_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_MULTI_TAX_CLASS;
      $this->enabled = ((MODULE_SHIPPING_MULTI_STATUS == 'True') ? true : false);

      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_MULTI_ZONE > 0) ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_MULTI_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
        while ($check = tep_db_fetch_array($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
            $check_flag = true;
            break;
          }
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }
    }

// class methods
    function quote($method = '') {
      global $order, $cart;

      // ----------------------------------------------
      $max = -9999999;  $found_item = null; $extra_charge = 0;

      foreach($cart->shipping_array as $k => $v) {
        $extra_charge += $v['extra'] * $v['qty'];
        if($v['handling'] > $max) {
          $max = $v['handling'];
          $found_item = $v;
          $extra_charge -= $found_item['extra'];
        }
      }

      $main_charge = $found_item['handling'];
      $sub_charge = $extra_charge;
      $surcharge = $cart->surcharge_shipping;
      // ----------------------------------------------

      $shipment = array(array('id' => 'priority', 'title' => 'Priority', 'cost' => $main_charge + $sub_charge + $surcharge + MODULE_SHIPPING_MULTI_HANDLING), array('id' => 'normal', 'title' => 'Normal', 'cost' => $main_charge + $sub_charge + $surcharge));

      $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_MULTI_TEXT_TITLE, 'methods' => $shipment);
                            
       switch ( $method ) {
        case 'priority':
          $this->quotes['methods'] = array(array('id' => 'priority', 'title' => 'Priority', 'cost' => $main_charge + $sub_charge + $surcharge + MODULE_SHIPPING_MULTI_HANDLING));
          break;
        case 'normal':
          $this->quotes['methods'] = array(array('id' => 'normal', 'title' => 'Normal', 'cost' => $main_charge + $sub_charge + $surcharge));
          break;
        default:
      }

      if ($this->tax_class > 0) {
        $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
      }

      if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

      return $this->quotes;
    }

    function check() {
      if (!isset($this->_check)) {
        $check_query = tep_db_query("select configuration_value from configuration where configuration_key = 'MODULE_SHIPPING_MULTI_STATUS'");
        $this->_check = tep_db_num_rows($check_query);
      }
      return $this->_check;
    }

    function install() {
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Multi Rate Shipping', 'MODULE_SHIPPING_MULTI_STATUS', 'True', 'Do you want to offer multi rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_MULTI_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_MULTI_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_MULTI_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_MULTI_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
    }

    function remove() {
      tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_SHIPPING_MULTI_STATUS', 'MODULE_SHIPPING_MULTI_HANDLING', 'MODULE_SHIPPING_MULTI_TAX_CLASS', 'MODULE_SHIPPING_MULTI_ZONE', 'MODULE_SHIPPING_MULTI_SORT_ORDER');
    }
  }

Here's the file.... Also it doesn't work with any shipping module as long as the customer isn't logged in. When I select a different shipping module, the page reloads clearing out the shipping quotes and it asks me to login to redeem discount coupon. 

 

Post a clean Bootstrap shopping_cart.php file and I'll test it.

 

Thanks

Edited by discxpress

Share this post


Link to post
Share on other sites

Hello @@discxpress,

 

It sounds strange, on my teststore it works with standard shipping modules and other users also reported that it works. Seems to be something with your modifications.

Here the original bs shopping cart file with only the content modification:

 
You could try to add the following variables to the global list in cm_cart_shipping_estimator.php line 58:
$main_charge, $sub_charge, $surcharge
So it should look like this:
      global $oscTemplate, $currencies, $request_type, $cart, $order, $total_count, $method, $module, $shipping, $navigation, $cart_country_id, $cart_zone, $total_weight, $language, $main_charge, $sub_charge, $surcharge;

Then please post your shipping module + language file as a file attachment, not the code. Like this it's easier to install on my test-store and try. :)

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

×