LemonStand Documentation

shop:onFilterShippingOptions event

The shop:onFilterShippingOptions event allows to filter the shipping option list before it is displayed on the checkout pages. The event handler should accept a single parameter - the options array. The array contains the following fields:

  • options - a array of shipping options (Shop_ShippingOption class instances)
  • country_id - shipping country identifier
  • state_id - shipping state identifier
  • zip - shipping ZIP/Postal code
  • city - shipping city
  • total_price - total price of all order items
  • total_volume - total volume of all order items
  • total_weight - total weight of all order items
  • total_item_num - total number of order items
  • order_items - a list of order items (Shop_OrderItem or Shop_CartItem objects, depending on the caller context)
  • customer_group_id - identifier of the customer group

The handler should return an updated options array. Please note, that for multi-option shipping methods (like USPS) you may need to update the $sub_options field, instead of removing the whole option from the result array.

Event handler example:

public function subscribeEvents()
{
  Backend::$events->addEvent('shop:onFilterShippingOptions', $this, 'filter_shipping_options');
}

public function filter_shipping_options($params)
{
  // Remove option with the "post" API key
  
  $result = array();
  foreach ($params['options'] as $option)
  {
    if ($option->ls_api_code != 'post')
      $result[] = $option;
  }
  
  return $result;
}

Next: cms:onGetPageFieldOptions event
Previous: core:onInitialize event
Return to Handling LemonStand events