Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Ship In Cart


Guest

Recommended Posts

HI,

@raiwa I installed this module (Ship In Cart 5.2 CE Phoenix) on Phoenix v1.0.7.12 (PHP 7.4.13) following the installation instructions, however there is one issue, when customer is not logged in (guest customer) on adding the product it goes to https://mysite.com//shopping_cart.php?ceid=57c6602bba76b4b4181caf6e61fed327, on a blank page with error  

This page isn’t working
mysite.uk is currently unable to handle this request.
HTTP ERROR 500

But When customer is logged in, there is not issue, all works well. 

Please advise how to fix this error. 
Thanks

Edited by zeeshop
Link to comment
Share on other sites

Hi @zeeshop,

Ship in cart requires an update for 1.0.7.12+ which will probably come for the 1.0.8.0 release.

I recommend you to stick with 1.0.7.11 for now, other apps will probably also break.

Merry christmas
Rainer

Link to comment
Share on other sites

Just now, zeeshop said:

Thanks, unable to go back to previous version.

I will wait for your update for 1.0.7.12 +. Till then I will keep it disable.

 

You should always:

- have a backup to be able to roll back

- test an update on a separate sandbox store before updateing a live store

Link to comment
Share on other sites

@zeeshop,

Hotfix for Phoenix 1.0.7.12:

In includes/modules/content/cm_sc_shipping.php line 64 add this:

              public function get_country_id() {
                return null;
              }
              public function get_zone_id() {
                return null;
              }

so the whole snippet should look like this:

          if (!isset($GLOBALS['customer'])) {
            $GLOBALS['customer'] = new class {
              public function fetch_to_address($to = null) {
                return [];
              }
              public function get($key, $to = 0) {
                return null;
              }
              public function get_default_address_id() {
                return null;
              }
              public function get_country_id() {
                return null;
              }
              public function get_zone_id() {
                return null;
              }
           };
          }

or just use this file:

cm_sc_shipping.php

 

However there may appear other issues.

Link to comment
Share on other sites

  • 5 weeks later...

No sure if this is because of version 0.13.

I get the following errors

Notice: Undefined index: subtotal in includes/modules/shipping/zipcanadapost.php on line 59

Notice: Undefined index: state in includes/modules/shipping/zipcanadapost.php on line 402

Notice: Undefined index: city in includes/modules/shipping/zipcanadapost.php on line 409

Notice: Undefined index: subtotal in includes/modules/shipping/zipcanadapost.php on line 374

Notice: Undefined index: customer_id in includes/modules/shipping/zipcanadapost.php on line 260
Error Code: Server Error Msg: /rs/ship/price: cvc-simple-type 1: element {http://www.canadapost.ca/ws/ship/rate}postal-code of type {http://www.canadapost.ca/ws/ship/rate}PostalCodeType may not be empty

Warning: Invalid argument supplied for foreach() in includes/system/versioned/1.0.7.4/shipping.php on line 99


So it looks like its trying to get/use info before it's even been submitted

image.thumb.png.619d438c0ec4dce0479b0499c28ccbb4.png

After i entered the required info, it still complains about missing vars

image.thumb.png.b7d4b95d0bd32832a10b83497eb74ce6.png

 

Link to comment
Share on other sites

Subtotal: You need to have the order totals module installed. I checked and $order->info[subtotal] is set.

State and Postal code gets set when the update button is submitted. You may add a text to make it more clear.

City is not available for guests/not logged in users. Not sure why it is needed. Postal code should be enough to retrieve a quote.
I you get a quote retrieved without it, just ignore the notice error.

customer_id has already been discussed in the other thread.

All notice errors can be ignored/supressed output or  catched/checked if they are set in the shipping module.

 

 

 

Link to comment
Share on other sites

@gsmiley007,

Please confirm that you need the city input. I'll then consider it to be added in the next update.

Link to comment
Share on other sites

Hi raiwa, 

@zipurman was kinda of enough to help me troubleshoot his shipping module with your in cart module. 

this is what he said:

The issue with the errors is that the $order object should have those indexes. If another addon changes the values in the $order object, then all things after that wont work. I can only guess as to what is happening there, but something you are using is changing the $order object.

The $order->info['subtotal'] is required for the value of the order, which is needed for insurance.

The  $order->delivery['city'] is  required for calculating the destination.

Link to comment
Share on other sites

Hi Guy @gsmiley007,

It's not that ship in cart changes the core $order object. Ship in cart creates the $order object  already in the shopping cart where core doesn't have it created yet.

Once the customer logs in, all indexes are correct created and there is no problem at all.

The problem you report appears because ship in cart creates the $order object for not logged in customers with a minimum of indexes to show shipping costs.

It works perfect for most shipping modules, but of course, if a specific shipping module requires additional indexes, they must be created specifically for this shipping module,

 

I had a deeper look and yes, the $order->info['subtotal'] index is not available yet for the shipping modules, because the order total module loads after the ship in cart module.

You can fix it using $_SESSION[cart]->show_total() instead of $order->info['subtotal'] if it is not set. Please ask @zipurman if he can do it and test it for you. Other shipping modules (fedex for example) use also $_SESSION[cart]->show_total(). There may appear also incompatibilities with other addons like the admin order editor.

I have no canadapost account and can't test it. But something like this should do it:

line 59 change to:

                'total_value'     => (isset($order->info['subtotal'])? number_format( ceil( $order->info['subtotal'] ), 2, '.', '' ) : number_format( ceil( $_SESSION[cart]->show_total() ), 2, '.', '' )),

 

Or wait for the next update, I can then set $order->info['subtotal'] like this in the ship in cart module.

For the city input, please wait a couple of days for the next update, I'll add it for you.

 

best regards
Rainer

Edited by raiwa
Link to comment
Share on other sites

Hi @gsmiley007, @zipurman,

Working on the ship in cart update I found that an error was introduced in one of the last updates.

$GLOBALS['cart'] is wrong, it should be $_SESSION['cart']. Thats why $order->info[subtotal] is not set in the shipping modules, even it is set in the ship in cart module.

To fix it, just replace for now in cm_sc_shipping.php all instances of $GLOBALS['cart'] with $_SESSION['cart'].

 

 

Link to comment
Share on other sites

@gsmiley007, @raiwa

I have updated the Canada Post (2.1.1) Mod here:

https://phoenixaddons.com/knowledgebase/canada-post-rest-module/

The 'city' is not required for this mod, but I have been keeping all of my shipping mods the same so it is required by others. For now, I have adjusted so the code is skipping 'city' if it is not defined. I also have it loading the $_SESSION['cart']->show_total() if the $order->info['subtotal'] is not defined.

Hope that helps.

Zip

Link to comment
Share on other sites

@gsmiley007,

Here is the updated cm_sc_shipping.php :

cm_sc_shipping.php

you need to uninstall/reinstall the module.

city and subtotal are now available in the shipping modules.

Please try and let me know .I'll then upload tomorrow the updated package.

Edited by raiwa
Link to comment
Share on other sites

6 hours ago, gsmiley007 said:

@raiwa

Stupid question, but do i replace both cm_sc_shipping.php with the one you provided me?

./includes/modules/content/shopping_cart/cm_sc_shipping.php
./includes/languages/english/modules/content/shopping_cart/cm_sc_shipping.php
 

only: ./includes/modules/content/shopping_cart/cm_sc_shipping.php

the other language  file is different, just open both and you'll see.

 

Please use the below new version and follow the update instructions.

You need to switch on state, zip and city in the settings.

To show a quote on first time page load, fill in a default zip and city.

The customer_id error must be addressed in the canadapost shipping module. @zipurman did it i the newest version 2.1.1. Make sure you are using that one.

Quote

Also does this module require a user login before the shipping quotes are shown?

If all the required fields are filled in, it shows the quote without login.

Edited by raiwa
Link to comment
Share on other sites

Uploaded:

Ship In Cart Phoenix 5.3

 
  Compatibility:
  OsC CE Phoenix 1.0.5.1+
  Tested with Phoenix 1.0.7.13/1.0.7.14 pre release
  PHP: 7.0 - 7.4
 
Changes Vers. 5.3:
  - Added optional City input required for some shipping modules.
  - Fixed wrong cart global to session.
  - tested with Phoenix 1.0.7.13 and 1.0.7.14 pre release.

 

Link to comment
Share on other sites

Hi @gsmiley007.

The store country and store zone is used by default. This is the order object available in the shipping modules on first time load:

order Object ( [info] => Array ( [subtotal] => 8.99 [total] => 8.99 [currency] => USD [currency_value] => 1.00000000 ) [totals] => Array ( ) [products] => Array ( [0] => Array ( [qty] => 1 [name] => Grapefruit [model] => GPF-1 [price] => 8.9900 [final_price] => 8.99 [weight] => 0.40 [id] => 8 [tax] => 0 [tax_description] => Unknown tax rate ) ) [customer] => Array ( ) [delivery] => Array ( [postcode] => 75203 [city] => Sant Iscle [country] => Array ( [id] => 223 [title] => United States [iso_code_2] => US [iso_code_3] => USA ) [country_id] => 223 [format_id] => 2 [zone_id] => 18 ) [billing] => Array ( ) [content_type] => physical [id] => ) 

As you can see $order->delivery['country']['id'] and $order->delivery['zone_id'] is set.

I believe zone code or name should be retrieved in the shipping module. Other shipping modules are doing this.

Link to comment
Share on other sites

If it is not possible/doable to retrieve the state in the canada shipping module, try this version which sets it also on first time load:

cm_sc_shipping.php

Link to comment
Share on other sites

@gsmiley007,

Please use this version. In the other version above I forgot to remove a debug line and I cleaned up some code:

cm_sc_shipping.php

Please report back, and I'll upload the updated package.

Link to comment
Share on other sites

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