Jump to content
ednique

[Contribution] Ship In Cart

Recommended Posts

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

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


Get the latest Responsive osCommerce CE (community edition) 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

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

Please post the file.

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

@@discxpress,

 

Please add also "$customer_id" to the globals list, just found that it's also missing for the customer address query.

Share this post


Link to post
Share on other sites

@@raiwa

 

Since this won't work with any shipping method while the customer is not logged in, it's becoming obvious that it has something to do with how my store is set up or it's clashing with another module.

 

I'll investigate more.

 

Thanks

Share this post


Link to post
Share on other sites

@@discxpress,

 

I found an issue in the module which could produce your problem. The zone id wasn't included in the shipping array.

Please try with the modified attached cm_cart_shipping_estimator.php:

 

Share this post


Link to post
Share on other sites

@@raiwa

 

 

@@discxpress,

 

I found an issue in the module which could produce your problem. The zone id wasn't included in the shipping array.

Please try with the modified attached cm_cart_shipping_estimator.php:

I tried your file and still no luck. I believe there's nothing wrong with your mod but more a problem with my site. Maybe there's a small conflict with another mod somewhere. Like a needle in a haystack.

 

Thanks for your help.

Share this post


Link to post
Share on other sites

Hi,

 

Attention: cm_cart_shipping_estimator.php

 

echo '<br>$selected_address' . $selected_address;
echo '<br>$sendto' . $sendto;
echo '<br>$cart_address_id' . $cart_address_id;

 

Debug-Modus?!?

Edited by rubberfashion

Share this post


Link to post
Share on other sites

Hello Dave @@rubberfashion,

 

Thank you for your report. Yes this was for debugging and I forgot to remove it, sorry. I just uploaded a new package with the cleaned file.

 

regards

Rainer

Share this post


Link to post
Share on other sites

Hello @@vampirehunter,

 

You can see it on my demo store:

http://www.sarfotostock.com/osCommerce234bs/

 

The module is placed at the bottom of the shopping cart page below the "Checkout" button or PayPal express payment button.

 

regards

Rainer

Edited by raiwa

Share this post


Link to post
Share on other sites

@@raiwa

 

Hi Rainer

 

I was playing around again with your addon and was wondering...

 

For example, if you choose United States and click the update button the state drop down will list all states.

But Albania or Gabon don't have zones/states defined and therefore it shows only please select inside the state drop down.

 

Now instead of having an empty state drop down would it not be nicer to have it hidden for countries without zones?

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

×