Free Shipping method without product weight

  • Posts: 5
  • Thank you received: 0
13 years 4 months ago #4079

Hi, is it posible?

sorry for my english

Rodrigo

Please Log in or Create an account to join the conversation.

  • Posts: 81622
  • Thank you received: 13084
  • MODERATOR
13 years 4 months ago #4081

Hi,
If you don't have a weight on a product, no shipping selection will be asked to the user.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 3 months ago #4793

Would it be possible to change the shipping plug-in API to include a canDisplayShipping() method?

If not defined then behaviour is as at present.
i.e. when no weight defined then treat product(s) as virtual.

If defined then the shipping plug-in will decide for itself (e.g. from product fields) whether it is valid to display or not.

Shipping methods will display if any canDisplayShipping() method returns true, but will only display those methods for which canDisplayShipping() is true.

This avoids the need to add dummy / meaningless weights to products just to get the shipping options to display.

We are looking at 'Local Delivery' and 'Local Delivery with Installation' shipping options and weight may not be the primary variable.
E.G. installation offered with some products, not relevant with others.

Please Log in or Create an account to join the conversation.

  • Posts: 81622
  • Thank you received: 13084
  • MODERATOR
13 years 3 months ago #4797

There is already the function onShippingDisplay which has this role.
The function onShippingDisplay is called with all the order information (in the variable $order) and the shipping methods (in the variable $dbrates) so that the shipping plugin can add the valid shipping methods (in the variable $usable_rates).

So in that function, you could parse the product information like this:
foreach($order->products as $k => $product){
//do something here
}

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 3 months ago #4812

From a further quick look at the code it still means that a weight must be specified somewhere in order to trigger a shipping method.
See controllers/checkout.php where you have code like this:

$shipping = ( bccomp(@$this->cartData->weight,0,5)>0 ? true : false );
if($shipping){
  $class = hikashop::get('class.shipping');
  $methods =& $class->getShippings($this->cartData);
Could this be changed to something like:
$class = hikashop::get('class.shipping');
$methods =& $class->getShippings($this->cartData);
$shipping = !empty($methods);
if($shipping){
Taking the manual shipping plugin as an example the first line of onShippingDisplay in manual/manual.php could then be changed from:
function onShippingDisplay(&$order,&$dbrates,&$usable_rates,&$messages){
  if(empty($dbrates)){
to:
function onShippingDisplay(&$order,&$dbrates,&$usable_rates,&$messages){
  if (bccomp(@$order->weight,0,5)>0 ? false : true) {
    return false;
  }
  if(empty($dbrates)){
This would maintain the existing behaviour while moving responsibility for the weight check into the shipping plug-in where it would be accessible to any developer writing a new shipping plug-in.

I notice this weight check occurs elsewhere in controllers/checkout.php so there might be other ramifications of this suggestion which would need investigation.

Please Log in or Create an account to join the conversation.

  • Posts: 81622
  • Thank you received: 13084
  • MODERATOR
13 years 3 months ago #4824

Yes, that could be possible. We will look at doing that for next release. As you pointed out, there is more to it than just those two places and we will need to review the checkout carefully when doing it.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 3 months ago #4858

Thanks.

Please Log in or Create an account to join the conversation.

Time to create page: 0.084 seconds
Powered by Kunena Forum