本文整理匯總了PHP中Magento\Sales\Test\Fixture\OrderInjectable::getCouponCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderInjectable::getCouponCode方法的具體用法?PHP OrderInjectable::getCouponCode怎麽用?PHP OrderInjectable::getCouponCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Sales\Test\Fixture\OrderInjectable
的用法示例。
在下文中一共展示了OrderInjectable::getCouponCode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test
/**
* 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: setCoupon
/**
* 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!');
}
}