Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with ot_shipping due the free shipping


sinopia

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']);
	    }

 

Link to comment
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. 

Link to comment
Share on other sites

  • 1 year later...
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?

Link to comment
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

Link to comment
Share on other sites

  • 4 months later...

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.

Link to comment
Share on other sites

  • 1 year later...

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.',
        ],
      ];
    }

  }

 

Link to comment
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;
      }
    }

 

Link to comment
Share on other sites

  • 2 weeks later...
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

 

Link to comment
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

 

Link to comment
Share on other sites

  • 1 month later...
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
Link to comment
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
Link to comment
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

Link to comment
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
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...