本文整理汇总了PHP中Varien_Event_Observer::getCreditmemo方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getCreditmemo方法的具体用法?PHP Varien_Event_Observer::getCreditmemo怎么用?PHP Varien_Event_Observer::getCreditmemo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getCreditmemo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resetCreditMemoOrder
/**
* Called when refunding an order.
*
* @param Varien_Event_Observer $observer
*/
public function resetCreditMemoOrder(Varien_Event_Observer $observer)
{
/* @var $order Mage_Sales_Model_Order */
$order = $observer->getCreditmemo()->getOrder();
/* @var $contactQueue Bronto_Order_Model_Queue */
Mage::getModel('bronto_order/queue')->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())->setBrontoImported(null)->save();
}
示例2: sales_order_payment_refund
public function sales_order_payment_refund(Varien_Event_Observer $observer)
{
$payment = $observer->getPayment();
$creditmemo = $observer->getCreditmemo();
if (!$creditmemo->getTransactionKey()) {
$creditmemo->setTransactionKey($payment->getTransactionKey())->save();
$payment->setTransactionKey(null)->save();
//the transaction key needs to be reset after every refund
}
$order = $creditmemo->getOrder();
$this->_updateRefundedOrderStatus($creditmemo, $order, true);
return $this;
}
示例3: salesOrderPaymentRefund
/**
* Method to send a partial (refund) or total (cancel) refund to aplazame when a creditmemo is created
*
* @param Varien_Event_Observer $observer
* @return $this
*/
public function salesOrderPaymentRefund($observer)
{
/** @var Mage_Sales_Model_Order_Payment $payment */
$payment = $observer->getPayment();
/** @var Mage_Sales_Model_Order_Creditmemo $creditmemo */
$creditmemo = $observer->getCreditmemo();
/** @var Mage_Sales_Model_Order $order */
$order = $payment->getOrder();
if (!$this->is_aplazame_payment($order)) {
return $this;
}
$remainingAmountAfterRefund = $order->getBaseGrandTotal() - $order->getBaseTotalRefunded();
$refundedTotal = $creditmemo->getBaseGrandTotal();
/** @var Aplazame_Aplazame_Model_Api_Client $client */
$client = Mage::getModel('aplazame/api_client');
if ($remainingAmountAfterRefund == 0) {
//total is refunded so we cancel order at aplazame side
$client->cancelOrder($order);
} else {
//partial refund so we refund at aplazame side
$client->refundAmount($order, $refundedTotal);
}
return $this;
}
示例4: salesOrderCreditmemoRefund
/**
* Change deal_qty and deal_bought if refound Credit memo
*
* @param Varien_Event_Observer $observer observed object
*/
public function salesOrderCreditmemoRefund(Varien_Event_Observer $observer)
{
$arguments = $this->_getRequest()->getParam('creditmemo');
$modelOrderItem = Mage::getModel('sales/order_item');
$modelProduct = Mage::getModel('catalog/product');
$items = $observer->getCreditmemo()->getAllItems();
foreach ($items as $item) {
$orderItem = $modelOrderItem->load($item->getOrderItemId());
if ($orderItem->getDealStat()) {
$qty = $orderItem->getQtyOrdered() - $orderItem->getQtyRefunded();
if ($item->getQty() != $qty || !$arguments['adjustment_negative']) {
$product = $modelProduct->load($item->getProductId());
$product->setDealQty($product->getDealQty() + $item->getQty())->setDealBought($product->getDealBought() - $item->getQty())->save();
}
}
}
}
示例5: submitCancellations
/**
* @param Varien_Event_Observer $observer
*/
public function submitCancellations($observer)
{
/** @var Mage_Sales_Model_Order_Creditmemo $creditMemo */
$creditMemo = $observer->getCreditmemo();
$data['order'] = $creditMemo->getOrder();
$data['credit_memo'] = $creditMemo;
$event = new Varien_Event($data);
$observer = new Varien_Event_Observer();
$observer->setEvent($event);
$this->cancelOrder($observer);
}
示例6: creditmemoSaveAfter
/**
* Triggered after credit memo is saved
*
* @param Varien_Event_Observer $observer Contains Order and CreditMemo objects
*/
public function creditmemoSaveAfter(Varien_Event_Observer $observer)
{
try {
/* @var $creditMemo Mage_Sales_Model_Order_Creditmemo */
$creditMemo = $observer->getCreditmemo();
/* @var $order Mage_Sales_Model_Order */
$order = Mage::getModel('sales/order');
$order->load($creditMemo->getOrderId());
$inputData = array('credit_memo' => $creditMemo, 'order' => $order);
foreach ($creditMemo->getItemsCollection() as $item) {
/* @var $item Mage_Sales_Model_Order_Creditmemo_Item */
if ($item->getOrderItem()->getQtyToRefund()) {
$isPartial = true;
}
//If the item is sent back to stock send an update to stock message
//We have a dependency on the Mage_CatalogInventory module to
//ensure that the observer responsible for returning the qty to stock
//has already been called.
if ($item->hasBackToStock()) {
if ($item->getBackToStock() && $item->getQty()) {
$productId = $item->getProductId();
$sku = $item->getSku();
$stockItem = Mage::getModel('cataloginventory/stock_item')->load((int) $productId);
Mage::helper('xcom_xfabric')->send('com.x.inventory.v1/StockItemUpdate/StockItemUpdated', array('stock_item' => $stockItem, 'product_sku' => $sku));
}
}
}
if (!empty($isPartial) && $isPartial) {
Mage::helper('xcom_xfabric')->send('com.x.ordermanagement.v2/ProcessSalesChannelOrder/PartialOrderReturn', $inputData);
} else {
Mage::helper('xcom_xfabric')->send('com.x.ordermanagement.v2/ProcessSalesChannelOrder/OrderReturn', $inputData);
}
} catch (Exception $exception) {
$this->_handleException($exception);
}
return $this;
}
示例7: sales_order_creditmemo_save_before
public function sales_order_creditmemo_save_before(Varien_Event_Observer $observer)
{
$post = Mage::app()->getFrontController()->getAction()->getRequest()->getPost('creditmemo');
// If the order was not payed with capayable, the field 'capayable_amount' will not be available in the creditmemo totals form, so we skip it.
if (!isset($post['capayable_amount'])) {
return NULL;
}
$creditCapayableAmount = (double) $post['capayable_amount'];
$baseCreditCapayableAmount = (double) $post['capayable_amount'];
$cm = $observer->getCreditmemo();
$order = $cm->getOrder();
$_maxAllowed = $order->getBaseCapayableFee() + $order->getBaseCapayableFeeTaxAmount() - ($order->getBaseCapayableFeeRefunded() + $order->getBaseCapayableFeeTaxAmountRefunded());
// 5.95
// The creditmemo numbers are allready modified by Tritac_Capayable_Model_Creditmemo_Total
// The payment fee from the order is already added to the GrandTotal in that Model.
// That has to be correct according to the submitted payment-fee refund.
$_origBaseCapayableFee = $cm->getBaseCapayableFee();
$_origBaseCapayableFeeTaxAmount = $cm->getBaseCapayableFeeTaxAmount();
$_origCapayableFee = $cm->getCapayableFee();
$_origCapayableFeeTaxAmount = $cm->getCapayableFeeTaxAmount();
$_taxRate = $_origBaseCapayableFee > 0 ? $_origBaseCapayableFeeTaxAmount / $_origBaseCapayableFee : 0;
// $_baseTotalCorrection must be applied on creditmemo.grand_total and creditmemo.base_grand_total
$_baseTotalCorrection = $baseCreditCapayableAmount - ($_origBaseCapayableFee + $_origBaseCapayableFeeTaxAmount);
$_factor = $baseCreditCapayableAmount / ($_origBaseCapayableFee + $_origBaseCapayableFeeTaxAmount);
$_baseRefund = $_factor * $_origBaseCapayableFee;
$_baseTaxRefund = $_factor * $_origBaseCapayableFeeTaxAmount;
$_baseTaxCorrection = $_baseTaxRefund - $_origBaseCapayableFeeTaxAmount;
$_baseCorrection = $_baseRefund - $_origBaseCapayableFee;
if ($baseCreditCapayableAmount > $_maxAllowed) {
Mage::throwException(Mage::helper('capayable')->__('Maximum Payment Fee amount allowed to refund is: %s (Incl. Tax)', $order->getBaseCurrency()->format($_maxAllowed, null, false)));
}
$cm->setGrandTotal($cm->getGrandTotal() + $_baseTotalCorrection);
$cm->setBaseGrandTotal($cm->getBaseGrandTotal() + $_baseTotalCorrection);
$cm->setBaseTaxAmount($cm->getBaseTaxAmount() + $_baseTaxCorrection);
$cm->setTaxAmount($cm->getTaxAmount() + $_baseTaxCorrection);
$order->setBaseTaxRefunded($cm->getBaseTaxAmount());
$order->setTaxRefunded($cm->getTaxAmount());
$order->setBaseTotalRefunded($order->getBaseTotalOfflineRefunded() + $order->getBaseTotalOnlineRefunded());
$order->setTotalRefunded($order->getTotalOfflineRefunded() + $order->getTotalOnlineRefunded());
$cm->setBaseCapayableFee($_baseRefund);
$cm->setCapayableFee($_baseRefund);
$cm->setBaseCapayableFeeTaxAmount($_baseTaxRefund);
$cm->setCapayableFeeTaxAmount($_baseTaxRefund);
$order->setBaseCapayableFeeRefunded($_baseRefund);
$order->setCapayableFeeRefunded($_baseRefund);
$order->setBaseCapayableFeeTaxAmountRefunded($_baseTaxRefund);
$order->setCapayableFeeTaxAmountRefunded($_baseTaxRefund);
}