本文整理汇总了PHP中Magento\Framework\DataObject::getOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::getOrder方法的具体用法?PHP DataObject::getOrder怎么用?PHP DataObject::getOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DataObject
的用法示例。
在下文中一共展示了DataObject::getOrder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* Method is invoked before save
*
* @param \Magento\Framework\DataObject $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\DataObject $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\DataObject $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: _getParentTransactionId
/**
* Get payflow transaction id from parent transaction
*
* @param \Magento\Framework\DataObject $payment
* @return string
*/
protected function _getParentTransactionId(\Magento\Framework\DataObject $payment)
{
if ($payment->getParentTransactionId()) {
return $this->transactionRepository->getByTransactionId($payment->getParentTransactionId(), $payment->getId(), $payment->getOrder()->getId())->getAdditionalInformation(self::TRANSPORT_PAYFLOW_TXN_ID);
}
return $payment->getParentTransactionId();
}
示例5: cancel
/**
* Cancel payment
*
* @param \Magento\Framework\DataObject $payment
* @return void
*/
public function cancel(\Magento\Framework\DataObject $payment)
{
if (!$payment->getOrder()->getInvoiceCollection()->count()) {
$this->void($payment);
}
}
示例6: _callDoAuthorize
/**
* Call DoAuthorize
*
* @param int $amount
* @param \Magento\Framework\DataObject $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 DataObject
*/
protected function _buildPlaceRequest(DataObject $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();
$request->setCurrency($order->getBaseCurrencyCode());
$request = $this->fillCustomerContacts($order, $request);
return $request;
}
示例8: buildRequest
/**
* Prepare request to gateway
*
* @param \Magento\Framework\DataObject|\Magento\Payment\Model\InfoInterface $payment
* @return \Magento\Authorizenet\Model\Request
* @link http://www.authorize.net/support/AIM_guide.pdf
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function buildRequest(\Magento\Framework\DataObject $payment)
{
/** @var \Magento\Sales\Model\Order $order */
$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');
break;
case self::REQUEST_TYPE_AUTH_ONLY:
$request->setXAllowPartialAuth($this->getConfigData('allow_partial_authorization') ? 'True' : 'False');
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 (!empty($order)) {
$billing = $order->getBillingAddress();
if (!empty($billing)) {
$request->setXFirstName($billing->getFirstname())->setXLastName($billing->getLastname())->setXCompany($billing->getCompany())->setXAddress($billing->getStreetLine(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->getStreetLine(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;
}