Ejemplo n.º 1
0
 /**
  * Given a Cart, return a set of Valid ShippingRanges satisfied.
  *
  * @param ShippingCollectionEvent $event Event
  *
  * @return $this Self object
  */
 public function addCustomShippingMethods(ShippingCollectionEvent $event)
 {
     if (!$this->plugin->isEnabled()) {
         return $this;
     }
     $cart = $event->getCart();
     $carrierRanges = $this->shippingRangesProvider->getAllShippingRangesSatisfiedWithCart($cart);
     foreach ($carrierRanges as $carrierRange) {
         $event->addShippingMethod(new ShippingMethod('custom-shipping-method-' . $carrierRange->getId(), $carrierRange->getCarrier()->getName(), $carrierRange->getName(), '', $carrierRange->getPrice()));
     }
 }
Ejemplo n.º 2
0
 /**
  * Checks if the plugin should be disabled
  *
  * @param GetResponseEvent $event The response event
  */
 public function handle(GetResponseEvent $event)
 {
     if ($this->plugin->isEnabled() && $this->wizardStatus->isWizardFinished()) {
         $this->plugin->setEnabled(false);
         $this->pluginObjectManager->flush($this->plugin);
     }
 }
Ejemplo n.º 3
0
 /**
  * Renders the mini wizard bar
  *
  * @param EventInterface $event The event
  */
 public function renderMiniWizard(EventInterface $event)
 {
     if ($this->plugin->isEnabled() && $this->isVisible() && !$this->wizardStatus->isWizardFinished()) {
         $stepsFinished = $this->wizardStatus->getStepsFinishStatus();
         $activeStep = $this->wizardStatus->getNextStep();
         $firstCarrier = $this->carrierRepository->findOneBy(['enabled' => true], ['id' => 'ASC']);
         $firstCarrier = $firstCarrier instanceof CarrierInterface ? $firstCarrier : false;
         $this->appendTemplate('@ElcodiStoreSetupWizard/Wizard/wizard.html.twig', $event, $this->plugin, ['stepsFinished' => $stepsFinished, 'activeStep' => $activeStep, 'isMiniWizard' => true, 'carrier' => $firstCarrier]);
     }
 }
 /**
  * Handles the event redirecting to the wizard if the user is visiting the
  * dashboard
  *
  * @param GetResponseEvent $event The response event
  */
 public function handle(GetResponseEvent $event)
 {
     if ($this->plugin->isEnabled() && !$this->wizardStatus->isWizardFinished()) {
         $request = $event->getRequest();
         $currentRoute = $this->getCurrentRequestRoute($request);
         if ('admin_homepage' == $currentRoute) {
             $event->setResponse(new RedirectResponse($this->urlGenerator->generate($this->wizardRoutes->getDefaultWizardRoute())));
         }
     }
 }