Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Ship In Cart


Guest

Recommended Posts

you need to add $customer_country_id, $customer_zone_id to the globals list.

Link to comment
Share on other sites

Hello Nicolas @@cinolas,

 

Forget the last post. I had a deeper look now and you just need to load the shipping class before the order total class:

      // load the selected shipping module
      require('includes/classes/shipping.php');
      $shipping_modules = new shipping($shipping);

      require('includes/classes/order_total.php');
      $order_total_modules = new order_total;
      $order_total_modules->process();
				
      if ( MODULE_ORDER_TOTAL_INSTALLED ) {
        $pa_order_total .= '	<div class="panel-body">';
        $pa_order_total .= '		<table class="pull-right">';
        $pa_order_total .= 			$order_total_modules->output();
        $pa_order_total .= '		</table>';
        $pa_order_total .= ' </div>'; // end body
      }

Like this you do not need anything else. You can also clean up your global list you need only: global $oscTemplate, $cart

and if you remove : if (($cart->count_contents() > 0)) {

which is not needed on the checkout payment page, you can leave only: global $oscTemplate

 

If you have a look on the checkout confirmation page, you'll see that it's done there like this:

// load the selected shipping module
  require('includes/classes/shipping.php');
  $shipping_modules = new shipping($shipping);

  require('includes/classes/order_total.php');
  $order_total_modules = new order_total;
  $order_total_modules->process();

rgds

Rainer

Link to comment
Share on other sites

Rainer, @@raiwa

Thank you SO MUCH. This is precisely the area of php that I know nothing about, that is to say most of php hehe. What I'm saying is I could've dug for a thousand years and not figured that out. Or taken an online course in php anyway...

 

It works beautifully!

 

best regards.

Link to comment
Share on other sites

  • 2 months later...

fyi, http_client.php is now removed as of pull #545

      	// shipping cost
      	require('includes/classes/http_client.php'); // shipping in basket

I haven't tested; however, I do not see any calls for this class in the latest code.

Link to comment
Share on other sites

Link to comment
Share on other sites

osCommerce now requires cURL to be enabled for the base install, so that should be used in place of the HTTP class in any module that needs to communicate with an external server. I'm not aware of any modern module that still uses the HTTP class. If there is one, it should be converted to use cURL.

 

Regards

Jim

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

Link to comment
Share on other sites

  • 3 months later...

Hi Raiwa,

Great work this modular shopping module!

I made a small additional module called continue shopping. Basically its just a button that allows the user to get easy back to the store.  (see attachment). If the code is ok by you maybe you can add it to an update of the modular shipping module.

Also I would like to ask if you already managed to provide something that If the user selects a shipping method he is not guided to checkout_shipping but to checkout_payment.

 
 

cm_sc_continue_shopping.php

continue_shopping.php

cm_sc_continue_shopping.php

Link to comment
Share on other sites

Hello Hans @koopmanh,

Thank you, I'll check the modules, but I believe they should be upoaded as a separate add-on. They are independant from the ship in cart modules. Let me know if you wish to pack and upload them yourself. Otherwise I'll do it. Just please give me one week or so, I'm actually travelling.

For the checkout issue, I sent you a PM.

rgds

Rainer

Link to comment
Share on other sites

  • 4 weeks later...

I have a tiny problem, and have had a quick look through some of the pages, but cant for the life of me find the fix for it.

I am using the latest 3.7 Version, on a 2.3.4 BS site...

If I have a shipping module that gives out a cost of 0.00 it does not show up in the list of delivery options for a customer who is not logged in, but does bring it up if the customer is logged in.

If I used that same shipping module and get it to output a price of 0.01 it does come up, so don't think its anything to do with the store country being missing or anything like that, it simply doesn't give it as an option as it has a price of 0.00

Massive thanks to anyone that can help me out with this one.

Link to comment
Share on other sites

Hello Andrew @Enzo_UK,

Please check if you have the store country filled in and if your module is post code based, activate the post code option to show and fill in the store post code into the ship in cart module.

If it still doesn't show, please post the module and I'll have a look.

Just for curiosity: why 0.00 shipping cost. There are other free shipping modules or strore pick up modules which are proved to work correct with ship in cart.

 

rgds

Rainer

Link to comment
Share on other sites

35 minutes ago, raiwa said:

Just for curiosity: why 0.00 shipping cost. There are other free shipping modules or strore pick up modules which are proved to work correct with ship in cart

The built in free shipping only seems to work on a whole country 'national' level, but this way I can offer free shipping just to some postcode areas.

In the UK parcel delivery prices vary a lot according to postcode, so if I want to offer free shipping over £50... its okay for most of the country where it will only cost me £6, but I simply cant afford to subsidise someone on a remote Scottish island for £18 worth of delivery on a £50 order.

Quote

Please check if you have the store country filled in and if your module is post code based, activate the post code option to show and fill in the store post code into the ship in cart module.

It was a silly error on my part, as I was trying to get this particular shipping module to only show if the cart subtotal is over £60, but for some reason it doesn't work for a first time visitor, but does once they are logged in.

	   if ($this->enabled == true) {
		global $order;
		if ($order->info['subtotal'] > '60'){
		 $this->enabled = true;
	   } else {
		 $this->enabled = false;
		}

But does work perfectly for both first time visitors and logged in customers if I use total instead of subtotal.

	if ($order->info['total'] > '60'

Thanks for the speedy response, even if it was my own strange error that I had created rather than being something built in the contribution.

Link to comment
Share on other sites

No sorry, its still doing something weird... I haven't fixed it.  lol....

It is something to do with the totals and stuff though, as if I use Subtotal it doesn't show up at all unless its a logged in customer, and if I use Total it behaves a bit weird, as if you have say £55 goods, and £5 shipping showing from another shipping module it will offer the choice of free shipping as the Total is £60, but as soon as you pick the free shipping module then the total has gone down to £55.

 

Edited by Enzo_UK
Link to comment
Share on other sites

Hello Andrew @Enzo_UK,

 

try to integrate your order total check in the class constructor function instead of the check function.

See this example for the zone check:

  // class constructor
    function __construct() {
      global $order;
      if ( $this->enabled == true ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE_UK_MAIN_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;
        }
      }
    }

 

Edited by raiwa
Link to comment
Share on other sites

You could include a check if $order->info['subtotal'] is defined and use then $cart->show_total() instead.

Link to comment
Share on other sites

  • 3 months later...

Hello Bill @phi148,

Sorry, but what is MVS, can you explain please.

 

rgds

Rainer

Link to comment
Share on other sites

Hello Bill @phi148,

Sorry, no experience with this I never used it. You may get support in the MVS support forum.

Best regards

Rainer

Link to comment
Share on other sites

  • 4 months later...

Uploaded:

Ship In Cart BS reloaded 4.0

Changes Vers. 4.0:

  - updated to 2.3.4.1. CE Frozen
  - Updated template name to 2.3.4.1 CE Frozen naming standard
  - Updated include template to 2.3.4.1 CE Frozen auto filename.
  - Hide message no shipping mwethod available for virtual carts
  - Hide shipping address for logged in users if virtual cart

 

Link to comment
Share on other sites

I have installed this great addon :)

I am wondering if there is an easy mod for the following problem:

As EU dealer, I must display all prices with 19% VAT. I have many customers from outside the EU, and I was hoping the addon would not only display shippig costs for these but the order total as well - in other words the  final price (with or without VAT, depending from the country they come from.)

After selecting the country, all the VAT itself of the shipping costs and product costs is displayed properly (so there are all kind of routines to check tax rates for logged-in or non-logged-in customers anyway)

BUT the subtotal is still the price with VAT , e.g. 400€ instead of 340€. The customer still needs to create an account an log-in just to see how much the product will cost him :(

Any ideas how to change this?
(sorry if this has already been discussed, I scanned the previous posts but there are 36 pages...)

Link to comment
Share on other sites

Hello Ingo @inra311,

try the following:

in includes/modules/content/shopping_cart/cm_sc_shipping.php, line47, add to the global list:

      global $customer_zone_id, $customer_country_id;

same file around line 154, find:

		        $cart_country_id = $_POST['country_id'];
		        tep_session_register('cart_country_id');
		        //add state zone_id
		        $cart_zone = isset($_POST['zone_id'])? $_POST['zone_id'] : null;
		        tep_session_register('cart_zone');
		        $cart_zip_code = (isset($_POST['zip_code'])? $_POST['zip_code'] : null);
		        tep_session_register('cart_zip_code');

change to:

		        $cart_country_id = $_POST['country_id'];
		        tep_session_register('cart_country_id');
		        $customer_country_id = $cart_country_id;
		        tep_session_register('customer_country_id');
		        //add state zone_id
		        $cart_zone = isset($_POST['zone_id'])? $_POST['zone_id'] : null;
		        tep_session_register('cart_zone');
		        $customer_zone_id = $cart_zone;
		        tep_session_register('customer_zone_id');
		        $cart_zip_code = (isset($_POST['zip_code'])? $_POST['zip_code'] : null);
		        tep_session_register('cart_zip_code');

 

in: includes/functions/general.php, within the "tep_get_tax_rate" function

find:

      if (!tep_session_is_registered('customer_id')) {

and change to:

      if (!tep_session_is_registered('customer_country_id')) {

this will update the subtotal if the country in shipping estimator is changed to a country without tax.

The products price in shopping cart will be updated on the next page load, because the customer_country_id is registered after the product list loading.

All product prices will then be shown without tax if the customer continues shopping.

Link to comment
Share on other sites

Ingo @inra311,

just found that it is better to add the code to the product listing module cm_sc_product_listing.php:

    function execute() {
      global $oscTemplate, $cart, $products, $currencies, $languages_id, $any_out_of_stock;
      global $customer_zone_id, $customer_country_id;
	  
      $content_width = (int)MODULE_CONTENT_SC_PRODUCT_LISTING_CONTENT_WIDTH;
      
      if ($cart->count_contents() > 0) {
        // register country_id for tax 
        if ( isset($_POST['country_id']) ) {
          $customer_country_id = $_POST['country_id'];
          tep_session_register('customer_country_id');
          $customer_zone_id = isset($_POST['zone_id'])? $_POST['zone_id'] : null;
          tep_session_register('customer_zone_id');
        }
        $any_out_of_stock = 0;
        $products = $cart->get_products();
        $products_name = NULL;

and leave the shipping module unmodified but apply also the modification in general.php

Like this the product prices in the shopping cart get immediately updated too.

Please let me know if it is all ok. I'll then add it as an option to the package.

rgds

Rainer

Edited by raiwa
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...