Jump to content
sinopia

Help with ot_shipping due the free shipping

Recommended Posts

I've set the default cost manually, in case anyone needs I used this way in ot_shipping.php:

        // The line telling the savings on the shipping when it's free
        if ($order->delivery['country_id'] == STORE_COUNTRY) {
        	$total_saving = '<span style="color: red; text-decoration: line-through;">4€</span>';
    	} else {
    		$total_saving = '<span style="color: red; text-decoration: line-through;">8€</span>';
    	}

		if (($order->info['total'] - $order->info['shipping_cost']) >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) { // if free shipping
	        $this->output[] = array('title' => $order->info['shipping_method'] . ':',
	                                'text' => $total_saving . ' ' . $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']),
	                                'value' => $order->info['shipping_cost']);
	    } else {
	        $this->output[] = array('title' => $order->info['shipping_method'] . ':',
	                                'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']),
	                                'value' => $order->info['shipping_cost']);
	    }

 

Share this post


Link to post
Share on other sites
11 hours ago, sinopia said:

@clustersolutions Hi. That code for the savings looks very nice. You could possibility public it? 

@sinopia, I believe there were quite a few places that required core code mods, may be schema as well. I hv been waiting for a stable/finalized OSC frame work b4 further  dev...I would by then. Hope u known what I mean. 

Share this post


Link to post
Share on other sites
On 12/20/2017 at 5:07 PM, raiwa said:

instead of the free shipping option in ot_shipping, just use for example the flat shipping module. Rename the title and description to free shipping and modify the code to show it only if order total is more than 29.90.

within the class constructor


        if ($order->info['total']) > 29.90) {
          $check_flag = true;
        }
        
        if ($check_flag == false) {
          $this->enabled = false;
        }

rgds

Rainer

Tried inserting your code as suggested but getting Parse error: syntax error, unexpected '>' in /includes/modules/shipping/flat.php referring to if ($order->info['total']) > 29.90) {

Any help?

Share this post


Link to post
Share on other sites

Try adding another bracket "(" before the first one following the initial if....you have 1 opening bracket but 2 closing ones.

Dan

Share this post


Link to post
Share on other sites

Hoping for some advice to edit the code in the above post (which should read) -

if ($order->info['total'] > 29.90) {
          $check_flag = true;
        }
        
        if ($check_flag == false) {
          $this->enabled = false;
        }

for example - so the shipping module only shows when order total is more than 29.90 AND more than total shipping weight of 100 - if that is possible.

Many thanks.

Share this post


Link to post
Share on other sites
1 hour ago, Heatherbell said:

if ($order->info['total'] > 29.90) {

if ( ($order->info['total'] > 29.90) && ($shipping_weight > 100) ) {

You *might* need to globalise $shipping_weight ... see how it's done in (eg) zones.php

Share this post


Link to post
Share on other sites

Hi,

I like to put same option for customers to offer free shipping if they have item over £30 in their cart for UK only customers, rest of the world will get zone shipping module available.

I prefer to go with @raiwaoption below, if possible, Tried this with no success, I must be putting code in a wrong place.

On 3/13/2019 at 3:44 PM, Heatherbell said:

instead of the free shipping option in ot_shipping, just use for example the flat shipping module. Rename the title and description to free shipping and modify the code to show it only if order total is more than 29.90.

within the class constructor


        if ($order->info['total']) > 29.90) {
          $check_flag = true;
        }
        
        if ($check_flag == false) {
          $this->enabled = false;
        }

My /includes/modules/shipping/flat.php look like this, kindly advise what exactly to change/ modify. Thanks

<?php
/*
  $Id$

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

  Copyright (c) 2020 osCommerce

  Released under the GNU General Public License
*/

  class flat extends abstract_shipping_module {

    const CONFIG_KEY_BASE = 'MODULE_SHIPPING_FLAT_';

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

      $this->quotes = [
        'id' => $this->code,
        'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
        'methods' => [[
          'id' => $this->code,
          'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
          'cost' => $this->base_constant('COST') + $this->calculate_handling(),
        ]],
      ];

      $this->quote_common();

      return $this->quotes;
    }

    protected function get_parameters() {
      return [
        $this->config_key_base . 'STATUS' => [
          'title' => 'Enable Flat Shipping',
          'value' => 'True',
          'desc' => 'Do you want to offer flat rate shipping?',
          'set_func' => "tep_cfg_select_option(['True', 'False'], ",
        ],
        $this->config_key_base . 'COST' => [
          'title' => 'Shipping Cost',
          'value' => '5.00',
          'desc' => 'The shipping cost for all orders using this shipping method.',
        ],
        $this->config_key_base . 'TAX_CLASS' => [
          'title' => 'Tax Class',
          'value' => '0',
          'desc' => 'Use the following tax class on the shipping fee.',
          'use_func' => 'tep_get_tax_class_title',
          'set_func' => 'tep_cfg_pull_down_tax_classes(',
        ],
        $this->config_key_base . 'ZONE' => [
          'title' => 'Shipping Zone',
          'value' => '0',
          'desc' => 'If a zone is selected, only enable this shipping method for that zone.',
          'use_func' => 'tep_get_zone_class_title',
          'set_func' => 'tep_cfg_pull_down_zone_classes(',
        ],
        $this->config_key_base . 'SORT_ORDER' => [
          'title' => 'Sort Order',
          'value' => '0',
          'desc' => 'Sort order of display.',
        ],
      ];
    }

  }

 

Share this post


Link to post
Share on other sites
11 hours ago, zeeshop said:

kindly advise what exactly to change/ modify

The following works for us (with thanks to @ecartz for solution).
After:

const CONFIG_KEY_BASE = 'MODULE_SHIPPING_FLAT_';

Insert:

public function __construct() {
      parent::__construct();
    
      if ($this->enabled && isset($GLOBALS['order']->info['total']) && ($GLOBALS['order']->info['total'] < 30)) {
        $this->enabled = false;
      }
    }

 

Share this post


Link to post
Share on other sites
On 12/27/2020 at 9:47 AM, Heatherbell said:

The following works for us (with thanks to @ecartz for solution).
After:


const CONFIG_KEY_BASE = 'MODULE_SHIPPING_FLAT_';

Insert:

On 12/27/2020 at 9:47 AM, Heatherbell said:

The following works for us (with thanks to @ecartz for solution).
After:



const CONFIG_KEY_BASE = 'MODULE_SHIPPING_FLAT_';

Insert:



public function __construct() {
      parent::__construct();
    
      if ($this->enabled && isset($GLOBALS['order']->info['total']) && ($GLOBALS['order']->info['total'] < 30)) {
        $this->enabled = false;
      }
    }

 

 

 

Would you be able to do the same with weight?

EG. if the order is over £5.00 and 0.02kg or grams or any thing........... do not show

 

Share this post


Link to post
Share on other sites
On 8/10/2019 at 6:59 PM, burt said:

if ( ($order->info['total'] > 29.90) && ($shipping_weight > 100) ) {

You *might* need to globalise $shipping_weight ... see how it's done in (eg) zones.php

 

Share this post


Link to post
Share on other sites
On 12/27/2020 at 9:47 AM, Heatherbell said:

The following works for us (with thanks to @ecartz for solution).
After:


const CONFIG_KEY_BASE = 'MODULE_SHIPPING_FLAT_';

Insert:


public function __construct() {
      parent::__construct();
    
      if ($this->enabled && isset($GLOBALS['order']->info['total']) && ($GLOBALS['order']->info['total'] < 30)) {
        $this->enabled = false;
      }
    }

I was using this code for a while now for free shipping over £30, and it works fine for Stripe and PayPal direct payment option,  where it is possible to select shipping options from list at www.site.com/checkout_shipping.php.

I am using @raiwa's Ship in Cart module.

However, if I choose free shipping option from Shopping Cart page and use PayPal express checkout, after taking credit card details, paypal send customer to www.site.com/checkout_confirmation.php without free shipping option (Flat Rate module), instead it automatically select "zone based rates" module price. There is no option to chose free shipping, unless customer goes back to checkout_shipping.php page to select free shipping option, then it seems to finalise the order. 

Paypal Express Checkout, shipping settings are: 

1. Instant update is "true"

2.  Site is running SSL

Any advise to resolve this would be very appreciated.

Thanks

Edited by zeeshop

Share this post


Link to post
Share on other sites

I didn't check, bit I believe If using the PayPal express checkout button, the shipping must be selected at the PayPal page (once logged into the PayPAl zccount).

Edited by raiwa

Share this post


Link to post
Share on other sites

Thanks @raiwa, but in my case, on PayPal page after logging in or entering credit card details, it send the customer back to site.com/checkout_confirmation.php with no option to select free shipping instead zone method pre-selected (as explained above)

I noticed this issue was reported in past, but unable to find solution which can resolve this.

Thanks

Share this post


Link to post
Share on other sites

Ok, so issue seems to be PayPal, In-Context option, this option does not seems to be fetching Shipping methods. However If I set this on classic, it takes customer on PayPal site and there Shipping options are available and works fine.

Thanks

 

Share this post


Link to post
Share on other sites

Using Paypal express checkout if you want customer to return to your site to select shipping option then I found a solution from 2015 post which worked for me, just sharing it as this may benefit others too.

Set Instant update to "Disabled"

In /ext/modules/payment/paypal/express.php

tep_redirect(tep_href_link('checkout_confirmation.php', '', 'SSL'));
        } else {
          $_SESSION['appPayPalEcRightTurn'] = true;

          tep_redirect(tep_href_link('checkout_shipping.php', '', 'SSL'));

with 

//added to send customer back to checkout_shipping
          tep_session_register('appPayPalEcRightTurn');
          $appPayPalEcRightTurn = true;
		  tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
		  //tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'));

 

Edited by zeeshop

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

×