Jump to content
Sign in to follow this  
Bryce F

Option to pick up from store (no shipping)?

Recommended Posts

Hi there. I'm working on a website for a retail store. I currently have a flat-rate shipping cost enabled, which is fine. I'd also like to have an option where the customer can pick up the item directly from the store (and forgo the shipping charge).

 

I figured I'd approach this by creating another shipping module that allowed me to set a pick-up price (0). I cloned the flat-rate module and changed the appropriate variable and function names both in the cloned main flat.php file (includes/modules/shipping/pickup.php) and the cloned language flat.php file (includes/languages/english/modules/shipping/pickup.php). Oddly, when I try to install/uninstall the module, or use the module when checking out my cart, I get the following errors:

Warning: Cannot modify header information - headers already sent by (output started at /home/watermel/public_html/osc/includes/modules/shipping/pickup.php:55) in /home/watermel/public_html/osc/admin/includes/functions/general.php on line 22

I also get the same error (minus the "admin/" part of the path) when I access this module from the cart checkout.

 

If interested, here is my main pickup.php file, based on the flat.php:

<?php

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

// class constructor
   function pickup() {
     global $order;
     $this->code = 'pickup';
     $this->title = MODULE_SHIPPING_PICKUP_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_PICKUP_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_SHIPPING_PICKUP_SORT_ORDER;
     $this->icon = '';
     $this->enabled = ((MODULE_SHIPPING_PICKUP_STATUS == 'True') ? true : false);
   }


// class methods
   function quote($method = '') {
     global $order;
     $this->quotes = array('id' => $this->code,
                           'module' => MODULE_SHIPPING_PICKUP_TEXT_TITLE,
                           'methods' => array(array('id' => $this->code,
                                                    'title' => MODULE_SHIPPING_PICKUP_TEXT_WAY,
                                                    'cost' => MODULE_SHIPPING_PICKUP_COST)));
     if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
     return $this->quotes;
   }

   function check() {
     if (!isset($this->_check)) {
       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 
'MODULE_SHIPPING_PICKUP_STATUS'");
       $this->_check = tep_db_num_rows($check_query);
     }
     return $this->_check;
   }

   function install() {
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, 
configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable In-store Pickups', 
'MODULE_SHIPPING_PICKUP_STATUS', 'True', 'Do you want to offer in-store pickups?', '6', '0', 
'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, 
configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost',
'MODULE_SHIPPING_PICKUP_COST', '0.00', 'The shipping cost for all orders using this shipping method.', '6', '0', now())");
     tep_db_query("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_PICKUP_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0',
'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, 
configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order',
'MODULE_SHIPPING_PICKUP_SORT_ORDER', '6', 'Sort order of display.', '6', '0', now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     return array('MODULE_SHIPPING_PICKUP_STATUS', 'MODULE_SHIPPING_PICKUP_COST', 'MODULE_SHIPPING_PICKUP_TAX_CLASS', 
'MODULE_SHIPPING_PICKUP_SORT_ORDER');
   }
 }
?>

 

Am I going about this the wrong way? Is there an easier way? Thank you for your time.

Edited by Bryce F

Share this post


Link to post
Share on other sites

There is a store pick up module in the contributions. Basically it's a clone of flat rate, so the way you go, but after it exist, why to reinvent it?

 

I have it set up just for zones that customers can really reach, then combined with "cash on pickup" payment way (appearing only if somebody choose the spu shipping way and now I'm trying to make it to work together with a storelocator, where customers can choose in what store they want to pick up

Share this post


Link to post
Share on other sites

Thanks for the link. I used it to make a slight modification to my own pickup module, and it worked fine. (Reinventing the wheel only took about 10 minutes anyhow...)

 

Another question:

Is there a clean way to have the default shipping method be flat rate (rather than cheapest)? I was considering modifying the includes/classes/shipping.php->cheapest() function to choose the correct method, but I figure there has to be a better way...

 

Thanks!

Share this post


Link to post
Share on other sites

I would go directly to catalog/checkout_shipping.php and do something with this line

  if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest();

 

What if you change the cheapest to flat?

Share this post


Link to post
Share on other sites
I would go directly to catalog/checkout_shipping.php and do something with this line

  if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest();

 

What if you change the cheapest to flat?

 

Well, cheapest() seems to be returning an array, and I'm not sure exactly what I should replace it with in order to choose flat...

Share this post


Link to post
Share on other sites

I am also using the spu.php (Store Pick Up Contribution).

 

I was wondering if it is possible to modify it so that in checkout_shipping.php it only shows the title:

Collect your order R0.00 o

 

But in checkout_confirmation.php it will add an address etc.

Shipping Method (Edit)

Collect your order

My Shop Street

My Shop Suburb

My Shop Postcode

 

Is this possible?

Share this post


Link to post
Share on other sites

I would go directly to catalog/checkout_shipping.php and do something with this line

  if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest();

 

What if you change the cheapest to flat?

 

Multimixer was right about investigation this function.

I was having issues with the way that the check_out was handling the cheapest value default selected.

I implemented a Pickup At the Store option for those who are close to the store and can pick up their order, but OSC would always select the cheapest by default and some if not all but many users are so lame that they don't even take the time to overlook their shipping options and simply click continue and don;t even know that they selected the Pick Up option, only after they get the confirmation of their order they realise what they did. So long story short;

 

catalog/includes/classes/shipping.php

At the bottom look for function cheapest()

edit the line:

//if ($rates[$i]['cost'] < $cheapest['cost'])

Rem it out and replace with this one:

if ($rates[$i]['cost'] < $cheapest['cost'] && $rates[$i]['cost'] > 0)

 

This is basic php coding 101, select the cheapest but not ZERO!

 

This is pretty much the fist time I've ever contributed to a forum in my life, so be nice.

Share this post


Link to post
Share on other sites

Hi,

 

I'd like to change my store times as the ones shown in this module is incorrect. Not being an expert could you please tell me the file location and name that I need to edit.

 

Thank you

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
Sign in to follow this  

×