コード例 #1
0
 /**
  * Sales coupon report
  *
  * @param OrderInjectable $order
  * @param array $viewsReport
  * @return void
  */
 public function test(OrderInjectable $order, array $viewsReport)
 {
     // Precondition
     $order->persist();
     $this->orderIndex->open();
     $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]);
     $this->salesOrderView->getPageActions()->invoice();
     $this->orderInvoiceNew->getTotalsBlock()->submit();
     $this->reportStatistic->open();
     $this->reportStatistic->getGridBlock()->massaction([['report' => 'Coupons']], 'Refresh Statistics for the Last Day', true);
     // Steps
     $this->salesCouponReportView->open();
     $ruleName = $order->getCouponCode()->getName();
     if (isset($viewsReport['rules_list'])) {
         $viewsReport['rules_list'] = str_replace('%rule_name%', $ruleName, $viewsReport['rules_list']);
     }
     $this->salesCouponReportView->getFilterBlock()->viewsReport($viewsReport);
     $this->salesCouponReportView->getActionBlock()->showReport();
 }
コード例 #2
0
 /**
  * Set coupon to quote.
  *
  * @param OrderInjectable $order
  * @return void
  * @throws \Exception
  */
 protected function setCoupon(OrderInjectable $order)
 {
     if (!$order->hasData('coupon_code')) {
         return;
     }
     $url = $this->url . '/coupons/' . $order->getCouponCode()->getCouponCode();
     $data = ['cartId' => $this->quote, 'couponCode' => $order->getCouponCode()->getCouponCode()];
     $this->webapiTransport->write($url, $data, WebapiDecorator::PUT);
     $response = json_decode($this->webapiTransport->read(), true);
     $this->webapiTransport->close();
     if ($response !== true) {
         $this->eventManager->dispatchEvent(['webapi_failed'], [$response]);
         throw new \Exception('Could not apply coupon code!');
     }
 }