public function onApplicationEvent(\FS\Context\ApplicationEventInterface $event, \FS\Context\ConfigurableApplicationContextInterface $context)
 {
     $package = $event->getInput('package');
     $method = $event->getInput('method');
     $settings = $context->getComponent('\\FS\\Components\\Settings');
     $options = $context->getComponent('\\FS\\Components\\Options');
     $command = $context->getComponent('\\FS\\Components\\Shipping\\Command');
     $factory = $context->getComponent('\\FS\\Components\\Shipping\\Factory\\ShoppingCartRateRequestFactory');
     $client = $context->getComponent('\\FS\\Components\\Http\\Client')->setToken($options->get('token'));
     $notifier = $context->getComponent('\\FS\\Components\\Notifier')->scope('cart');
     $rateProcessorFactory = $context->getComponent('\\FS\\Components\\Shipping\\RateProcessor\\Factory\\RateProcessorFactory');
     // when store owner disable front end warning for their customer
     if ($options->equal('disable_api_warning', 'yes')) {
         $notifier->enableSilentLogging();
     }
     // no shipping address, alert customer
     if (empty($package['destination']['postcode'])) {
         $notifier->notice('Add shipping address to get shipping rates! (click "Calculate Shipping")');
         $notifier->view();
         return;
     }
     $response = $command->quote($client, $factory->setPayload(array('package' => $package, 'options' => $options, 'notifier' => $notifier))->getRequest());
     if (!$response->isSuccessful()) {
         $notifier->error('Flagship Shipping has some difficulty in retrieving the rates. Please contact site administrator for assistance.<br/>');
         $notifier->view();
         return;
     }
     $rates = $response->getBody();
     $rates = $rateProcessorFactory->getRateProcessor('ProcessRate')->getProcessedRates($rates, array('factory' => $rateProcessorFactory, 'options' => $options, 'instanceId' => property_exists($method, 'instance_id') ? $method->instance_id : false));
     foreach ($rates as $rate) {
         $method->add_rate($rate);
     }
     $notifier->view();
 }
 public function onApplicationEvent(\FS\Context\ApplicationEventInterface $event, \FS\Context\ConfigurableApplicationContextInterface $context)
 {
     $order = $event->getInput('order');
     $metaBox = $context->getComponent('\\FS\\Components\\Order\\MetaBox');
     $rp = $context->getComponent('\\FS\\Components\\Web\\RequestParam');
     $notifier = $context->getComponent('\\FS\\Components\\Notifier')->scope('shop_order', array('id' => $order->getId()));
     // load instance shipping method used by this shopping order
     $service = $order->getShippingService();
     $options = $context->getComponent('\\FS\\Components\\Options')->sync($service['instance_id'] ? $service['instance_id'] : false);
     $context->getComponent('\\FS\\Components\\Http\\Client')->setToken($options->get('token'));
     switch ($rp->request->get('flagship_shipping_shipment_action')) {
         case 'shipment-create':
             $metaBox->createShipment($order);
             break;
         case 'shipment-void':
             $metaBox->voidShipment($order);
             break;
         case 'shipment-requote':
             $metaBox->requoteShipment($order);
             break;
         case 'pickup-schedule':
             $metaBox->schedulePickup($order);
             break;
         case 'pickup-void':
             $metaBox->voidPickup($order);
             break;
     }
 }
 public function onApplicationEvent(\FS\Context\ApplicationEventInterface $event, \FS\Context\ConfigurableApplicationContextInterface $context)
 {
     $order = $event->getInput('order');
     $metaBox = $context->getComponent('\\FS\\Components\\Order\\MetaBox');
     $notifier = $context->getComponent('\\FS\\Components\\Notifier')->scope('shop_order', array('id' => $order->getId()));
     $metaBox->display($order);
 }
 public function onApplicationEvent(\FS\Context\ApplicationEventInterface $event, \FS\Context\ConfigurableApplicationContextInterface $context)
 {
     $fields = $event->getInput('fields');
     $notifier = $context->getComponent('\\FS\\Components\\Notifier');
     $validator = $context->getComponent('\\FS\\Components\\Validation\\SettingsValidator');
     $fields = $validator->validate($fields, $notifier);
     return $fields;
 }
 public function onApplicationEvent(\FS\Context\ApplicationEventInterface $event, \FS\Context\ConfigurableApplicationContextInterface $context)
 {
     $links = $event->getInput('links');
     if ($inputs['file'] == FLAGSHIP_SHIPPING_PLUGIN_BASENAME) {
         array_unshift($links, $context->getComponent('\\FS\\Components\\Html')->a('flagship_shipping_settings', __('Settings', FLAGSHIP_SHIPPING_TEXT_DOMAIN), array('escape' => true, 'target' => true)));
     }
     return $links;
 }
 public function onApplicationEvent(\FS\Context\ApplicationEventInterface $event, \FS\Context\ConfigurableApplicationContextInterface $context)
 {
     $methods = $event->getInputs();
     $settings = $context->getComponent('\\FS\\Components\\Settings');
     $id = $settings['FLAGSHIP_SHIPPING_PLUGIN_ID'];
     if (\version_compare(WC()->version, '2.6', '>=')) {
         $methods[$id] = '\\FS\\Configurations\\WordPress\\Shipping\\Method\\FlagShipWcShippingMethod';
     } else {
         include_once FLAGSHIP_SHIPPING_PLUGIN_DIR . 'src/Configurations/WordPress/Shipping/Method/Legacy_Flagship_WC_Shipping_Method.php';
         $methods[$id] = new \FlagShip_WC_Shipping_Method();
     }
     return $methods;
 }
 public function onApplicationEvent(\FS\Context\ApplicationEventInterface $event, \FS\Context\ConfigurableApplicationContextInterface $context)
 {
     $type = $event->getInput('type');
     $postIds = $event->getInputs('postIds');
     $pickup = $context->getComponent('\\FS\\Components\\Order\\Pickup');
     switch ($type) {
         case 'schedule':
             $pickup->schedulePickup($pickup->makeShoppingOrders($postIds));
             break;
         case 'void':
             $pickup->voidPickup($postIds);
             break;
         case 'reschedule':
             $pickup->reschedulePickup($postIds);
             break;
     }
 }