Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Community Contributed Add-Ons / Addon Shipping Modules / Make a shipping module to show a cost or not depending on the free shipping cart stat

Make a shipping module to show a cost or not depending on the free shipping cart stat

22 Apr 2013, 9:22 AM
#1
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #1 by enzo_ita

I want to make the pick up in shop module (the one mod by dr byte) to show a cost when nothing in the cart is free shipping, and do not show a cost when something in the cart is free shipping or the cart is free shipping because the freeoptions are met (ie value of the cart).

this is the file storepickup.php

<?php /** * @package shippingMethod * @copyright Copyright 2003-2013 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: multiple-choice edition, Feb 8, 2013 - based on: storepickup.php 14498 2009-10-01 20:16:16Z ajeh $ */ /** * Store-Pickup / Will-Call shipping method * */ class storepickup extends base { /** * $code determines the internal 'code' name used to designate "this" payment module * * @var string */ var $code; /** * $title is the displayed name for this payment method * * @var string */ var $title; /** * $description is a soft name for this payment method * * @var string */ var $description; /** * module's icon * * @var string */ var $icon; /** * $enabled determines whether this module shows or not... during checkout. * * @var boolean */ var $enabled; /** * constructor * * @return storepickup */ function storepickup() { global $order, $db; $this->code = 'storepickup'; $this->title = MODULE_SHIPPING_STOREPICKUP_TEXT_TITLE; $this->description = MODULE_SHIPPING_STOREPICKUP_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_STOREPICKUP_SORT_ORDER; $this->icon = ''; // add image filename here; must be uploaded to the /images/ subdirectory $this->tax_class = MODULE_SHIPPING_STOREPICKUP_TAX_CLASS; $this->tax_basis = MODULE_SHIPPING_STOREPICKUP_TAX_BASIS; $this->enabled = ((MODULE_SHIPPING_STOREPICKUP_STATUS == 'True') ? true : false); if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_STOREPICKUP_ZONE > 0) ) { $check_flag = false; $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_STOREPICKUP_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while (!$check->EOF) { if ($check->fields['zone_id'] < 1) { $check_flag = true; break; } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } $check->MoveNext(); } if ($check_flag == false) { $this->enabled = false; } } } /** * Obtain quote from shipping system/calculations * * @param string $method * @return array */ function quote($method = '') { global $order; $this->locations = explode(';', (string)MODULE_SHIPPING_STOREPICKUP_LOCATIONS_LIST); $this->methodsList = array(); foreach ($this->locations as $key => $val) { if ($method != '' && $method != $this->code . (string)$key) continue; $cost = MODULE_SHIPPING_STOREPICKUP_COST; $title = $val; if (strstr($val, ',')) { list($title, $cost) = explode(',', $val); } $this->methodsList[] = array('id' => $this->code . (string)$key, 'title' => trim($title), 'cost' => $cost); } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_STOREPICKUP_TEXT_TITLE, 'methods' => $this->methodsList); if ($this->tax_class > 0) { $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title); return $this->quotes; } /** * Check to see whether module is installed * * @return boolean */ function check() { global $db; if (!isset($this->_check)) { $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_STOREPICKUP_STATUS'"); $this->_check = $check_query->RecordCount(); } if ($this->_check > 0 && !defined('MODULE_SHIPPING_STOREPICKUP_LOCATIONS_LIST')) $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Pickup Locations', 'MODULE_SHIPPING_STOREPICKUP_LOCATIONS_LIST', 'Walk In', 'Enter a list of locations, separated by semicolons (;).<br>Optionally you may specify a fee/surcharge for each location by adding a comma and an amount. If no amount is specified, then the generic Shipping Cost amount from the next setting will be applied.<br><br>Examples:<br>121 Main Street;20 Church Street<br>Sunnyside,4.00;Lee Park,5.00;High Street,0.00<br>Dallas;Tulsa,5.00;Phoenix,0.00', '6', '0', now())"); return $this->_check; } /** * Install the shipping module and its configuration settings * */ function install() { global $db; $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Store Pickup Shipping', 'MODULE_SHIPPING_STOREPICKUP_STATUS', 'True', 'Do you want to offer In Store rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Pickup Locations', 'MODULE_SHIPPING_STOREPICKUP_LOCATIONS_LIST', 'Walk In', 'Enter a list of locations, separated by semicolons (;).<br>Optionally you may specify a fee/surcharge for each location by adding a comma and an amount. If no amount is specified, then the generic Shipping Cost amount from the next setting will be applied.<br><br>Examples:<br>121 Main Street;20 Church Street<br>Sunnyside,4.00;Lee Park,5.00;High Street,0.00<br>Dallas;Tulsa,5.00;Phoenix,0.00', '6', '0', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_STOREPICKUP_COST', '0.00', 'The shipping cost for all orders using this shipping method.', '6', '0', now())"); $db->Execute("insert into " . TABLE_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_STOREPICKUP_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_STOREPICKUP_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\'), ', now())"); $db->Execute("insert into " . TABLE_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_STOREPICKUP_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_STOREPICKUP_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); } /** * Remove the module and all its settings * */ function remove() { global $db; $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_STOREPICKUP\_%'"); } /** * Internal list of configuration keys used for configuration of the module * * @return array */ function keys() { return array('MODULE_SHIPPING_STOREPICKUP_STATUS', 'MODULE_SHIPPING_STOREPICKUP_LOCATIONS_LIST', 'MODULE_SHIPPING_STOREPICKUP_COST', 'MODULE_SHIPPING_STOREPICKUP_TAX_CLASS', 'MODULE_SHIPPING_STOREPICKUP_TAX_BASIS', 'MODULE_SHIPPING_STOREPICKUP_ZONE', 'MODULE_SHIPPING_STOREPICKUP_SORT_ORDER'); } }

Can someone help?
Thanks
Ciao from Italy
enzo

23 Apr 2013, 6:56 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Post #2 by rodg

enzo-ita:

I want to make the pick up in shop module to show a cost when nothing in the cart is free shipping

Am I reading this right and you wish to apply a 'shipping cost' for store pickups for products not eligible for free shipping?

Far be it for me to criticise your objectives, but I'd suspect that this could have a negative impact on any local sales you make. Why would you want to do that?

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

2 May 2013, 3:38 PM
#3
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #3 by enzo_ita

Hi,
thanks for your reply.
The word store pick up can be confusing.
Actually is "Delivery at Pick up Point".
Pick up point is a place close to your address that you can chose from a huge list, were you can go at your easy, also on Saturday, to pick up your parcel.
It can be very usefull for people who can not be at home at delivery time or want to pay cod and are not at home or do not want to give money to a nighborough, etc etc etc.
This is very close to a normal delivery service, therefore it must follow the rules of normal delivery.
I hope this makes it clear.
Do you have any suggestions about the code to mod?
Ciao from Italy.
enzo

2 May 2013, 9:46 PM
#4
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #4 by enzo_ita

I have created (it is just a copy of another working module) a file called pickuppoint.php.
Here it is:

// $Id: pickuppoint.php 1969 2013-05-03 06:57:21Z enzo $
//

  class pickuppoint {
    var $code, $title, $description, $icon, $enabled;

// class constructor
    function pickuppoint() {
      global $order, $db;

      $this->code = 'pickuppoint';
      $this->title = MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_CELERE3_PICKUPPOINT_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_BASIS;

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS == 'True') ? true : false);
      }

      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_CELERE3_PICKUPPOINT_ZONE > 0) ) {
        $check_flag = false;
        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_CELERE3_PICKUPPOINT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
        while (!$check->EOF) {
          if ($check->fields['zone_id'] < 1) {
            $check_flag =  true;
            break;
          } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
            $check_flag = true;
            break;
          }
          $check->MoveNext();
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }
 //     if (($this->enabled == true) && (IS_ADMIN_FLAG === false && $_SESSION['cart']->weight > 30)) $this->enabled = false;
    }

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

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_WAY,
                                                     'cost' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST)));
      if ($this->tax_class > 0) {
        $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
      }

      if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);

      return $this->quotes;
    }

    function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }

    function install() {
      global $db;
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Abilita la spedizione PickUpPoin via Paccocelere 3', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS', 'True', 'Abilitare la spedizione PickUpPoint via Paccocelere 3?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Costo di Spedizione', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST', '7.74', 'Spese di Spedizione per PickUpPoint Paccocelere 3 fino a 30 KG.', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Classe IVA', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_CLASS', '0', 'Applica la seguente aliquota IVA ai costi di spedizione.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Base di Tassa', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_BASIS', 'Shipping', 'Su quali basi vengono calcolate le Tasse sulle Spese di Spedizione.  Le opzioni sono:<br />Shipping - Basata sull\'indirizzo di Spedizione del Cliente<br />Billing - Basata sull\'indirizzo di Fatturazione del Cliente<br />Store - Basata sull\'indirizzo del Negozio se la Zona di Fatturazione/Spedizione è uguale alla Zona del Negozio', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Zona di Spedizione', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_ZONE', '0', 'Se viene selezionata una Zona, il metodo di spedizione viene abilitato solo per la Zona indicata.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Ordine di Visualizzazione', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_SORT_ORDER', '0', 'Ordine di Visualizzazione.', '6', '0', now())");
    }

    function remove() {
      global $db;
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_CELERE3\_PICKUPPOINT\_%'");
    }

    function keys() {
      return array('MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_CLASS', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_BASIS', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_ZONE', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_SORT_ORDER');
    }
  }
?>

It works without problemas but, given that this module has a cost for the user, what I want is to either:
Show this module only when the cart is free shipping (for any reason)
or better
show this module with a higher cost when the cart is not free shipping.
Can someone help with this?
Thanks
ciao from Italy
enzo

3 May 2013, 4:10 PM
#5
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #5 by enzo_ita

Hi, I have mod the file again so taht now it created when installed the field MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1 which will bear a different cost from MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST
Now I need help in understanding how to change the cod in this area

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

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_WAY,
                                                     'cost' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST)));

The mod should simply check the cart and

if ($free_ship_on == 'true')

it should use the value contained in MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1 instead.
Can someone help me?
I know it should not be difficult, but I do not know how to do it.
Thanks again.
Ciao from Italy
enzo

3 May 2013, 10:02 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #6 by ajeh

Could you zip both of your files for this so we can try it?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 May 2013, 6:22 AM
#7
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #7 by enzo_ita

Dear Linda,
thanks for answering.
You are always precious.
Are you coming to Italy soon?
Attached the files you required.
Ciao From Italy.
enzo
Attachment #12451
P.S. Please notice that the orginal title of the post does not reflect the actual objective. Now I want to show a different price for this module depending on the shipping cart status (free shipping or not)

4 May 2013, 1:30 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #8 by ajeh

Let's get specific and do some baby steps ...

Is your definition of Free Shipping defined as 0 weight or Always Free Shipping of every Product in the cart?

If the cart is Free Shipping, should this module show?

If the cart is NOT Free Shipping should this module show?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 May 2013, 4:21 PM
#9
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #9 by enzo_ita

A cart is free shipping when:
A minimum value of order is met
or
A product in the cart is always free shipping
or
A mix of always free shipping and not always free shipping products is in the cart even if the minimum order value is not met.

If the cart is free shipping the module is shown at xxx fee (MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST)
If the cart is not free shipping the module is show at yyy fee (MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1)

The free shipping module will be shown together with this module if the cart is free shipping, and the customer will have the possibility to choose this module instead of the free one. It will be possible to choose other shipping options.
The free shipping module will NOT be shown together with this module if the cart is free shipping, and the customer will have the possibility to choose this module instead of the other modules shown.
Thanks

4 May 2013, 5:03 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #10 by ajeh

Is this closer to what you are trying to do?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 May 2013, 6:11 PM
#11
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #11 by enzo_ita

Hi Linda,
yes close but not correct.
I have mod the code in red.
This because if it is free shipping, no matter why, COST_1 must be shown. Instead if the cart is not free shipping, COST must be shown.
########################################################################################################################_
// bof: show if 1 or more products is in the cart for Always Free Shipping
if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents()) {
// cart is ALL Always Free Shipping
$cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1;
} else {
// cart is Mixed Always Free Shipping and Not Always Free Shipping
$cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1;
}

  $this->quotes = array('id' => $this->code,
                        'module' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_TITLE,
                        'methods' => array(array('id' => $this->code,
                                                 'title' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_WAY,
                                                 'cost' => $cost)));

// eof: show if 1 or more products is in the cart for Always Free Shipping
############################################################################################################################################
The only check it should be done is the cart status and based on cart status free shipping or not free shipping CODE O CODE_1 should be shown.

I think the following code could work to check the cart status but when I try to use it it does not.
I have copied the code from the plugin free shipping qualifier and it works in the plugin that I use to warn the customer that his cart is not free shipping and suggest to buy more in order to get the free shipping.

 
$free_ship_on = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING;
if ($free_ship_on == 'true') 
{$cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1;} 
else 
{$cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST;}

Thanks again.
ciao from Italy
enzo

4 May 2013, 6:15 PM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #12 by ajeh

If you want to use:

if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents()) {
      // cart is ALL Always Free Shipping
        $cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST[B]_1[/B];
      } else {
      // cart is Mixed Always Free Shipping and Not Always Free Shipping
        $cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1;
      }

Does that mean you should be using in the ELSE:
MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 May 2013, 7:17 PM
#13
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #13 by enzo_ita

Yes you are right...Obviously.
This way it works.

 if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents()) {
      // cart is ALL Always Free Shipping
        $cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1;
      }// else {
      // cart is Mixed Always Free Shipping and Not Always Free Shipping
      //  $cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1;
     // }

But if the cart is free shipping because the minimum order value is met, the module does not show.

ciao ciao

4 May 2013, 7:45 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #14 by ajeh

and if you add:

if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents() || $_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING) {

IF not, also add at the top:

      if (!zen_get_shipping_enabled($this->code)) {$this->enabled = ((MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS == 'True') ? true : false);}
[B]      if ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING) {
        $this->enabled = true;
      }
[/B]

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 May 2013, 8:11 PM
#15
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #15 by enzo_ita

I have added in this way but it crashes.

// bof: show if 1 or more products is in the cart for Always Free Shipping
      if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents())|| $_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING) {

Then I have added in this way

// bof: show if 1 or more products is in the cart for Always Free Shipping
 if (!zen_get_shipping_enabled($this->code)) {$this->enabled = ((MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS == 'True') ? true : false);}
      if ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING) {
        $this->enabled = true;
      }
      if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents())|| $_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING) {

But still crashes.
I think I am not doing it correctly. could you please give higher "monkey proof" instructions?
ciao
enzo

4 May 2013, 11:53 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #16 by ajeh

Could you look in your debug directory and see what debug logs come up?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 May 2013, 12:03 AM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #17 by ajeh

For the Top of the file try:

// bof: show if 1 or more products is in the cart for Always Free Shipping
      // disable only when entire cart is free shipping
      if (!zen_get_shipping_enabled($this->code)) {$this->enabled = ((MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS == 'True') ? true : false);}

      if (!IS_ADMIN_FLAG) {
        if ($_SESSION['cart']->show_total() >= 100.00) {
          $this->enabled = true;
        }
        if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') > 0) {
          $this->enabled = true;
        }
      }
// eof: show if 1 or more products is in the cart for Always Free Shipping

and at the bottom:

// bof: show if 1 or more products is in the cart for Always Free Shipping
//      if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents()) {
      if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents() || $_SESSION['cart']->show_total() >= 100.00) {
      // cart is ALL Always Free Shipping
        $cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST;
      } else {
      // cart is Mixed Always Free Shipping and Not Always Free Shipping
        $cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1;
      }

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_WAY,
                                                     'cost' => $cost)));
// eof: show if 1 or more products is in the cart for Always Free Shipping

Note: the change from:
100.00

to use the amount that you set for:
MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING

set the 100.00 to what is the minimum order to get Free Shipping and if you have it set in the Modules ... Order Total ... Shipping ot_shipping then disable that ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 May 2013, 9:46 AM
#18
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #18 by enzo_ita

Hi Linda,
thank for your help.
Trough your help, I have learned a lot and I mod the file to perfection. Now it works exactly like I want.
The only thing I would like to do more, is to have this module automatically collect the minimum order value set. instead to have to set this manually in the module.
Below the final code:

<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004 The zen-cart developers                           |
// |                                                                      |
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This is a shipping module copied and modded by Linda Mc Grawth and   |
// | enzo lipomi. this module will show different shipping costs depending|
// | on the shopping cart free shipping status.                           |
// +----------------------------------------------------------------------+
// $Id: pickuppoint.php  2013-05-03 06:57:21Z Linda Mc Grawth and enzo
//

  class pickuppoint {
    var $code, $title, $description, $icon, $enabled;

// class constructor
    function pickuppoint() {
      global $order, $db;

      $this->code = 'pickuppoint';
      $this->title = MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_CELERE3_PICKUPPOINT_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_BASIS;


// bof: when to show 
      if (!zen_get_shipping_enabled($this->code)) 
	  {$this->enabled = ((MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS == 'True') ? true : false);
	  }
      if (!IS_ADMIN_FLAG) 
		{if ($_SESSION['cart']->show_total() >= 60.00) 
		{$this->enabled = true;
        }
        if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') > 0) 
		{$this->enabled = true;
        }
      	if ($_SESSION['cart']->show_total() <= 60.00) 
		{$this->enabled = true;
		}
		else 
		{
		if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','0') > 0) 
		{$this->enabled = true;}
		}
		}
// eof: when to show

      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_CELERE3_PICKUPPOINT_ZONE > 0) ) {
        $check_flag = false;
        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_CELERE3_PICKUPPOINT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
        while (!$check->EOF) {
          if ($check->fields['zone_id'] < 1) {
            $check_flag =  true;
            break;
          } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
            $check_flag = true;
            break;
          }
          $check->MoveNext();
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }}

     function quote($method = '') {
      global $order;

// bof: cost pick up depending on cart condition
      //cost if either 1 or more products is in the cart for Always Free Shipping or cart is Over Minimum
      if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents() || $_SESSION['cart']->show_total() >= 60.00) 
      {$cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1;
	  }
	  //cost if cart is Not Free Shipping
      if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','0') == $_SESSION['cart']->count_contents() and $_SESSION['cart']->show_total() <= 60.00) 
      {$cost = MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST;
      }
//eof: cost pick up depending on cart condition  

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_CELERE3_PICKUPPOINT_TEXT_WAY,
                                                     'cost' => $cost)));
      if ($this->tax_class > 0) 
      {$this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
      }

      if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);

      return $this->quotes;
    }

    function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }

    function install() {
      global $db;
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Abilita la spedizione PickUpPoin via Paccocelere 3', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS', 'True', 'Abilitare la spedizione PickUpPoint via Paccocelere 3?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Costo di Spedizione', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST', '7.74', 'Spese di Spedizione per PickUpPoint Paccocelere 3 fino a 30 KG.', '6', '0', now())");
	   $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Costo di Spedizione', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1', '9.99', 'Spese di Spedizione per PickUpPoint Paccocelere 3 fino a 30 KG. se free shipping', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Classe IVA', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_CLASS', '0', 'Applica la seguente aliquota IVA ai costi di spedizione.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Base di Tassa', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_BASIS', 'Shipping', 'Su quali basi vengono calcolate le Tasse sulle Spese di Spedizione.  Le opzioni sono:<br />Shipping - Basata sull\'indirizzo di Spedizione del Cliente<br />Billing - Basata sull\'indirizzo di Fatturazione del Cliente<br />Store - Basata sull\'indirizzo del Negozio se la Zona di Fatturazione/Spedizione è uguale alla Zona del Negozio', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Zona di Spedizione', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_ZONE', '0', 'Se viene selezionata una Zona, il metodo di spedizione viene abilitato solo per la Zona indicata.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Ordine di Visualizzazione', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_SORT_ORDER', '0', 'Ordine di Visualizzazione.', '6', '0', now())");
    }

    function remove() {
      global $db;
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_CELERE3\_PICKUPPOINT\_%'");
    }

    function keys() {
      return array('MODULE_SHIPPING_CELERE3_PICKUPPOINT_STATUS', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_COST_1','MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_CLASS', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_TAX_BASIS', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_ZONE', 'MODULE_SHIPPING_CELERE3_PICKUPPOINT_SORT_ORDER');
    }
  }
?>

Thanks again for your precious help and lessons. Please do not forget to contact me if youìll ever come to Milano Italy. I owe you one.
enzo
P.S. Please see if it possible to automatically set the minimum order.

5 May 2013, 1:03 PM
#19
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Post #19 by enzo_ita

Forget about the minimum order problem. Found the solution.
Ciao
enzo

5 May 2013, 1:13 PM
#20
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #20 by ajeh

On the minimum amount, did you try using the Free Shipping in the Shipping ot_shipping and set to disabled so that it is not used by the ot_shipping but can be used by the shipping module for the:
MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER

this way, you can set the amount in the Admin, but with it disabled, the Free Shipping for Shipping ot_shipping is ignored ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!