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. Each element is the Shop_ShippingOption object.
- 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. Note, that for multi-option shipping methods
(like USPS) you may need to update the
$sub_options property.
Usage 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->id] = $option;
}
return $result;
}