本文整理汇总了PHP中Magento\Framework\Object::getOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getOrder方法的具体用法?PHP Object::getOrder怎么用?PHP Object::getOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Object
的用法示例。
在下文中一共展示了Object::getOrder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* Method is invoked before save
*
* @param \Magento\Framework\Object $object
* @return $this
*/
public function beforeSave($object)
{
if ($object->getOrder()) {
$object->setOrderId($object->getOrder()->getId());
$object->setBillingAddressId($object->getOrder()->getBillingAddress()->getId());
}
return parent::beforeSave($object);
}
示例2: beforeSave
/**
* Perform operation before save
*
* @param \Magento\Framework\Object $object
* @return $this
*/
public function beforeSave($object)
{
if ($object->getOrder()) {
$object->setParentId($object->getOrder()->getId());
}
parent::beforeSave($object);
return $this;
}
示例3: displayPrices
/**
* Get "double" prices html (block with base and place currency)
*
* @param \Magento\Framework\Object $dataObject
* @param float $basePrice
* @param float $price
* @param bool $strong
* @param string $separator
* @return string
*/
public function displayPrices($dataObject, $basePrice, $price, $strong = false, $separator = '<br/>')
{
$order = false;
if ($dataObject instanceof \Magento\Sales\Model\Order) {
$order = $dataObject;
} else {
$order = $dataObject->getOrder();
}
if ($order && $order->isCurrencyDifferent()) {
$res = '<strong>';
$res .= $order->formatBasePrice($basePrice);
$res .= '</strong>' . $separator;
$res .= '[' . $order->formatPrice($price) . ']';
} elseif ($order) {
$res = $order->formatPrice($price);
if ($strong) {
$res = '<strong>' . $res . '</strong>';
}
} else {
$res = $this->priceCurrency->format($price);
if ($strong) {
$res = '<strong>' . $res . '</strong>';
}
}
return $res;
}
示例4: _buildRequest
/**
* Prepare request to gateway
*
* @param \Magento\Framework\Object|\Magento\Payment\Model\Info $payment
* @return \Magento\Authorizenet\Model\Authorizenet\Request
* @link http://www.authorize.net/support/AIM_guide.pdf
*/
protected function _buildRequest(\Magento\Framework\Object $payment)
{
$order = $payment->getOrder();
$this->setStore($order->getStoreId());
$request = $this->_getRequest()->setXType($payment->getAnetTransType())->setXMethod(self::REQUEST_METHOD_CC);
if ($order && $order->getIncrementId()) {
$request->setXInvoiceNum($order->getIncrementId());
}
if ($payment->getAmount()) {
$request->setXAmount($payment->getAmount(), 2);
$request->setXCurrencyCode($order->getBaseCurrencyCode());
}
switch ($payment->getAnetTransType()) {
case self::REQUEST_TYPE_AUTH_CAPTURE:
$request->setXAllowPartialAuth($this->getConfigData('allow_partial_authorization') ? 'True' : 'False');
if ($payment->getAdditionalInformation($this->_splitTenderIdKey)) {
$request->setXSplitTenderId($payment->getAdditionalInformation($this->_splitTenderIdKey));
}
break;
case self::REQUEST_TYPE_AUTH_ONLY:
$request->setXAllowPartialAuth($this->getConfigData('allow_partial_authorization') ? 'True' : 'False');
if ($payment->getAdditionalInformation($this->_splitTenderIdKey)) {
$request->setXSplitTenderId($payment->getAdditionalInformation($this->_splitTenderIdKey));
}
break;
case self::REQUEST_TYPE_CREDIT:
/**
* Send last 4 digits of credit card number to authorize.net
* otherwise it will give an error
*/
$request->setXCardNum($payment->getCcLast4());
$request->setXTransId($payment->getXTransId());
break;
case self::REQUEST_TYPE_VOID:
$request->setXTransId($payment->getXTransId());
break;
case self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE:
$request->setXTransId($payment->getXTransId());
break;
case self::REQUEST_TYPE_CAPTURE_ONLY:
$request->setXAuthCode($payment->getCcAuthCode());
break;
}
if ($this->getIsCentinelValidationEnabled()) {
$params = $this->getCentinelValidator()->exportCmpiData(array());
$request = \Magento\Framework\Object\Mapper::accumulateByMap($params, $request, $this->_centinelFieldMap);
}
if (!empty($order)) {
$billing = $order->getBillingAddress();
if (!empty($billing)) {
$request->setXFirstName($billing->getFirstname())->setXLastName($billing->getLastname())->setXCompany($billing->getCompany())->setXAddress($billing->getStreet(1))->setXCity($billing->getCity())->setXState($billing->getRegion())->setXZip($billing->getPostcode())->setXCountry($billing->getCountry())->setXPhone($billing->getTelephone())->setXFax($billing->getFax())->setXCustId($order->getCustomerId())->setXCustomerIp($order->getRemoteIp())->setXCustomerTaxId($billing->getTaxId())->setXEmail($order->getCustomerEmail())->setXEmailCustomer($this->getConfigData('email_customer'))->setXMerchantEmail($this->getConfigData('merchant_email'));
}
$shipping = $order->getShippingAddress();
if (!empty($shipping)) {
$request->setXShipToFirstName($shipping->getFirstname())->setXShipToLastName($shipping->getLastname())->setXShipToCompany($shipping->getCompany())->setXShipToAddress($shipping->getStreet(1))->setXShipToCity($shipping->getCity())->setXShipToState($shipping->getRegion())->setXShipToZip($shipping->getPostcode())->setXShipToCountry($shipping->getCountry());
}
$request->setXPoNum($payment->getPoNumber())->setXTax($order->getBaseTaxAmount())->setXFreight($order->getBaseShippingAmount());
}
if ($payment->getCcNumber()) {
$request->setXCardNum($payment->getCcNumber())->setXExpDate(sprintf('%02d-%04d', $payment->getCcExpMonth(), $payment->getCcExpYear()))->setXCardCode($payment->getCcCid());
}
return $request;
}
示例5: cancel
/**
* Cancel payment
*
* @param \Magento\Framework\Object $payment
* @return void
*/
public function cancel(\Magento\Framework\Object $payment)
{
if (!$payment->getOrder()->getInvoiceCollection()->count()) {
$this->void($payment);
}
}
示例6: _callDoAuthorize
/**
* Call DoAuthorize
*
* @param int $amount
* @param \Magento\Framework\Object $payment
* @param string $parentTransactionId
* @return \Magento\Paypal\Model\Api\AbstractApi
*/
protected function _callDoAuthorize($amount, $payment, $parentTransactionId)
{
$apiData = $this->_pro->getApi()->getData();
foreach ($apiData as $k => $v) {
if (is_object($v)) {
unset($apiData[$k]);
}
}
$this->_checkoutSession->setPaypalTransactionData($apiData);
$this->_pro->resetApi();
$api = $this->_setApiProcessableErrors()->setAmount($amount)->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())->setTransactionId($parentTransactionId)->callDoAuthorization();
$payment->setAdditionalInformation($this->_authorizationCountKey, $payment->getAdditionalInformation($this->_authorizationCountKey) + 1);
return $api;
}
示例7: _buildPlaceRequest
/**
* Return request object with information for 'authorization' or 'sale' action
*
* @param Object|Payment $payment
* @param float $amount
* @return Object
*/
protected function _buildPlaceRequest(Object $payment, $amount)
{
$request = $this->buildBasicRequest();
$request->setAmt(round($amount, 2));
$request->setAcct($payment->getCcNumber());
$request->setExpdate(sprintf('%02d', $payment->getCcExpMonth()) . substr($payment->getCcExpYear(), -2, 2));
$request->setCvv2($payment->getCcCid());
$order = $payment->getOrder();
if (!empty($order)) {
$request->setCurrency($order->getBaseCurrencyCode());
$orderIncrementId = $order->getIncrementId();
$request->setCurrency($order->getBaseCurrencyCode())->setInvnum($orderIncrementId)->setPonum($order->getId())->setComment1($orderIncrementId);
$request = $this->fillCustomerContacts($order, $request);
}
return $request;
}