本文整理匯總了PHP中Magento\Sales\Model\Order::getConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP Order::getConfig方法的具體用法?PHP Order::getConfig怎麽用?PHP Order::getConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Sales\Model\Order
的用法示例。
在下文中一共展示了Order::getConfig方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setOrderStateAndStatus
/**
* @param Order $order
* @param string $status
* @param string $state
* @return void
*/
protected function setOrderStateAndStatus(Order $order, $status, $state)
{
if (!$status) {
$status = $order->getConfig()->getStateDefaultStatus($state);
}
$order->setState($state)->setStatus($status);
}
示例2: check
/**
* Check order status before save
*
* @param Order $order
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function check(Order $order)
{
if (!$order->getId()) {
return $order;
}
if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) {
if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) {
if ($order->getState() !== Order::STATE_COMPLETE) {
$order->setState(Order::STATE_COMPLETE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_COMPLETE));
}
} elseif (floatval($order->getTotalRefunded()) || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo()) {
if ($order->getState() !== Order::STATE_CLOSED) {
$order->setState(Order::STATE_CLOSED)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CLOSED));
}
}
}
if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) {
$order->setState(Order::STATE_PROCESSING)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING));
}
return $this;
}
示例3: validateCoinGateCallback
/**
* @param Order $order
*/
public function validateCoinGateCallback(Order $order)
{
try {
if (!$order || !$order->getIncrementId()) {
$request_order_id = filter_input(INPUT_POST, 'order_id') ? filter_input(INPUT_POST, 'order_id') : filter_input(INPUT_GET, 'order_id');
throw new \Exception('Order #' . $request_order_id . ' does not exists');
}
$payment = $order->getPayment();
$get_token = filter_input(INPUT_GET, 'token');
$token1 = $get_token ? $get_token : '';
$token2 = $payment->getAdditionalInformation('coingate_order_token');
if ($token2 == '' || $token1 != $token2) {
throw new \Exception('Tokens do match.');
}
$request_id = filter_input(INPUT_POST, 'id') ? filter_input(INPUT_POST, 'id') : filter_input(INPUT_GET, 'id');
$this->coingate->getOrder($request_id);
if (!$this->coingate->success) {
throw new \Exception('CoinGate Order #' . $request_id . ' does not exist');
}
if (!is_array($this->coingate->response)) {
throw new \Exception('Something wrong with callback');
}
if ($this->coingate->response['status'] == 'paid') {
$order->setState(Order::STATE_PROCESSING, TRUE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING))->save();
} elseif (in_array($this->coingate->response['status'], array('invalid', 'expired', 'canceled'))) {
$order->setState(Order::STATE_CANCELED, TRUE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CANCELED))->save();
}
} catch (\Exception $e) {
exit('Error occurred: ' . $e);
}
}
示例4: validateKhipuCallback
/**
* @param Order $order
*/
public function validateKhipuCallback(Order $order)
{
try {
if (!$order || !$order->getIncrementId()) {
throw new \Exception('Order #' . $_REQUEST['order_id'] . ' does not exists');
}
$payment = $order->getPayment();
$notificationToken = isset($_POST['notification_token']) ? $_POST['notification_token'] : '';
if ($notificationToken == '') {
throw new \Exception('Invalid notification token.');
}
$configuration = new \Khipu\Configuration();
$configuration->setSecret($this->getConfigData('merchant_secret'));
$configuration->setReceiverId($this->getConfigData('merchant_id'));
$configuration->setPlatform('magento2-khipu', Payment::KHIPU_MAGENTO_VERSION);
$client = new \Khipu\ApiClient($configuration);
$payments = new \Khipu\Client\PaymentsApi($client);
try {
$paymentResponse = $payments->paymentsGet($notificationToken);
} catch (\Khipu\ApiException $exception) {
throw new \Exception(print_r($exception->getResponseObject(), TRUE));
}
if ($paymentResponse->getReceiverId() != $this->getConfigData('merchant_id')) {
throw new \Exception('Invalid receiver id');
}
if ($paymentResponse->getTransactionId() != $payment->getAdditionalInformation('khipu_order_token')) {
throw new \Exception('Invalid transaction id');
}
if ($paymentResponse->getStatus() != 'done') {
throw new \Exception('Payment not done');
}
if ($paymentResponse->getAmount() != number_format($order->getGrandTotal(), $this->getDecimalPlaces($order->getOrderCurrencyCode()), '.', '')) {
throw new \Exception('Amount mismatch');
}
if ($paymentResponse->getCurrency() != $order->getOrderCurrencyCode()) {
throw new \Exception('Currency mismatch');
}
$order->setState(Order::STATE_PROCESSING, TRUE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING))->save();
} catch (\Exception $e) {
exit('Error occurred: ' . $e);
}
}
示例5: _captureOrder
/**
* Capture order's payment using AIM.
*
* @param \Magento\Sales\Model\Order $order
* @return void
*/
protected function _captureOrder(\Magento\Sales\Model\Order $order)
{
$payment = $order->getPayment();
if ($payment->getAdditionalInformation('payment_type') == self::ACTION_AUTHORIZE_CAPTURE) {
try {
$payment->setTransactionId(null)->setParentTransactionId($this->getResponse()->getXTransId())->capture(null);
// set status from config for AUTH_AND_CAPTURE orders.
if ($order->getState() == \Magento\Sales\Model\Order::STATE_PROCESSING) {
$orderStatus = $this->getConfigData('order_status');
if (!$orderStatus || $order->getIsVirtual()) {
$orderStatus = $order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING);
}
if ($orderStatus) {
$order->setStatus($orderStatus);
}
}
$order->save();
} catch (\Exception $e) {
//if we couldn't capture order, just leave it as NEW order.
$this->_logger->logException($e);
}
}
}
示例6: setOrderStatusByState
/**
* Update Order Status and State
* @param \Magento\Sales\Model\Order $order
* @param string $state
*/
public function setOrderStatusByState($order, $state)
{
$order->setState($state)->setStatus($order->getConfig()->getStateDefaultStatus($state));
}