本文整理汇总了PHP中Magento\Sales\Model\Order\Creditmemo::getStore方法的典型用法代码示例。如果您正苦于以下问题:PHP Creditmemo::getStore方法的具体用法?PHP Creditmemo::getStore怎么用?PHP Creditmemo::getStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Sales\Model\Order\Creditmemo
的用法示例。
在下文中一共展示了Creditmemo::getStore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* Collect Weee amounts for the credit memo
*
* @param Creditmemo $creditmemo
* @return $this
*/
public function collect(Creditmemo $creditmemo)
{
$store = $creditmemo->getStore();
$totalTax = 0;
$baseTotalTax = 0;
$weeeTaxAmount = 0;
$baseWeeeTaxAmount = 0;
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$weeeAmountExclTax = ($this->_weeeData->getWeeeTaxInclTax($item) - $this->_weeeData->getTotalTaxAppliedForWeeeTax($item)) * $item->getQty();
$totalTax += $weeeAmountExclTax;
$baseWeeeAmountExclTax = ($this->_weeeData->getBaseWeeeTaxInclTax($item) - $this->_weeeData->getBaseTotalTaxAppliedForWeeeTax($item)) * $item->getQty();
$baseTotalTax += $baseWeeeAmountExclTax;
$item->setWeeeTaxAppliedRowAmount($weeeAmountExclTax);
$item->setBaseWeeeTaxAppliedRowAmount($baseWeeeAmountExclTax);
$weeeTaxAmount += $this->_weeeData->getWeeeTaxInclTax($item) * $item->getQty();
$baseWeeeTaxAmount += $this->_weeeData->getBaseWeeeTaxInclTax($item) * $item->getQty();
$newApplied = array();
$applied = $this->_weeeData->getApplied($item);
foreach ($applied as $one) {
$one['base_row_amount'] = $one['base_amount'] * $item->getQty();
$one['row_amount'] = $one['amount'] * $item->getQty();
$one['base_row_amount_incl_tax'] = $one['base_amount_incl_tax'] * $item->getQty();
$one['row_amount_incl_tax'] = $one['amount_incl_tax'] * $item->getQty();
$newApplied[] = $one;
}
$this->_weeeData->setApplied($item, $newApplied);
$item->setWeeeTaxRowDisposition($item->getWeeeTaxDisposition() * $item->getQty());
$item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxDisposition() * $item->getQty());
}
if ($this->_weeeData->includeInSubtotal($store)) {
$creditmemo->setSubtotal($creditmemo->getSubtotal() + $totalTax);
$creditmemo->setBaseSubtotal($creditmemo->getBaseSubtotal() + $baseTotalTax);
}
$creditmemo->setSubtotalInclTax($creditmemo->getSubtotalInclTax() + $weeeTaxAmount);
$creditmemo->setBaseSubtotalInclTax($creditmemo->getBaseSubtotalInclTax() + $baseWeeeTaxAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
return $this;
}
示例2: collect
/**
* Collect Weee amounts for the credit memo
*
* @param Creditmemo $creditmemo
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function collect(Creditmemo $creditmemo)
{
$store = $creditmemo->getStore();
$totalWeeeAmount = 0;
$baseTotalWeeeAmount = 0;
$totalWeeeAmountInclTax = 0;
$baseTotalWeeeAmountInclTax = 0;
$totalTaxAmount = 0;
$baseTotalTaxAmount = 0;
foreach ($creditmemo->getAllItems() as $item) {
$orderItem = $item->getOrderItem();
$orderItemQty = $orderItem->getQtyOrdered();
if (!$orderItemQty || $orderItem->isDummy() || $item->getQty() < 0) {
continue;
}
$ratio = $item->getQty() / $orderItemQty;
$orderItemWeeeAmountExclTax = $orderItem->getWeeeTaxAppliedRowAmount();
$orderItemBaseWeeeAmountExclTax = $orderItem->getBaseWeeeTaxAppliedRowAmnt();
$weeeAmountExclTax = $creditmemo->roundPrice($orderItemWeeeAmountExclTax * $ratio);
$baseWeeeAmountExclTax = $creditmemo->roundPrice($orderItemBaseWeeeAmountExclTax * $ratio, 'base');
$orderItemWeeeAmountInclTax = $this->_weeeData->getRowWeeeTaxInclTax($orderItem);
$orderItemBaseWeeeAmountInclTax = $this->_weeeData->getBaseRowWeeeTaxInclTax($orderItem);
$weeeAmountInclTax = $creditmemo->roundPrice($orderItemWeeeAmountInclTax * $ratio);
$baseWeeeAmountInclTax = $creditmemo->roundPrice($orderItemBaseWeeeAmountInclTax * $ratio, 'base');
$itemTaxAmount = $weeeAmountInclTax - $weeeAmountExclTax;
$itemBaseTaxAmount = $baseWeeeAmountInclTax - $baseWeeeAmountExclTax;
$weeeAmountAvailable = $this->_weeeData->getWeeeAmountInvoiced($orderItem) - $this->_weeeData->getWeeeAmountRefunded($orderItem);
$baseWeeeAmountAvailable = $this->_weeeData->getBaseWeeeAmountInvoiced($orderItem) - $this->_weeeData->getBaseWeeeAmountRefunded($orderItem);
$weeeTaxAmountAvailable = $this->_weeeData->getWeeeTaxAmountInvoiced($orderItem) - $this->_weeeData->getWeeeTaxAmountRefunded($orderItem);
$baseWeeeTaxAmountAvailable = $this->_weeeData->getBaseWeeeTaxAmountInvoiced($orderItem) - $this->_weeeData->getBaseWeeeTaxAmountRefunded($orderItem);
if ($item->isLast()) {
$weeeAmountExclTax = $weeeAmountAvailable;
$baseWeeeAmountExclTax = $baseWeeeAmountAvailable;
$itemTaxAmount = $weeeTaxAmountAvailable;
$itemBaseTaxAmount = $baseWeeeTaxAmountAvailable;
} else {
$weeeAmountExclTax = min($weeeAmountExclTax, $weeeAmountAvailable);
$baseWeeeAmountExclTax = min($baseWeeeAmountExclTax, $baseWeeeAmountAvailable);
$itemTaxAmount = min($itemTaxAmount, $weeeTaxAmountAvailable);
$itemBaseTaxAmount = min($itemBaseTaxAmount, $baseWeeeTaxAmountAvailable);
}
$totalWeeeAmount += $weeeAmountExclTax;
$baseTotalWeeeAmount += $baseWeeeAmountExclTax;
$item->setWeeeTaxAppliedRowAmount($weeeAmountExclTax);
$item->setBaseWeeeTaxAppliedRowAmount($baseWeeeAmountExclTax);
$totalTaxAmount += $itemTaxAmount;
$baseTotalTaxAmount += $itemBaseTaxAmount;
//Set the ratio of the tax amount in invoice item compared to tax amount in order item
//This information is needed to calculate tax per tax rate later
$orderItemTaxAmount = $orderItemWeeeAmountInclTax - $orderItemWeeeAmountExclTax;
if ($orderItemTaxAmount != 0) {
$taxRatio = [];
if ($item->getTaxRatio()) {
$taxRatio = unserialize($item->getTaxRatio());
}
$taxRatio[\Magento\Weee\Model\Total\Quote\Weee::ITEM_TYPE] = $itemTaxAmount / $orderItemTaxAmount;
$item->setTaxRatio(serialize($taxRatio));
}
$totalWeeeAmountInclTax += $weeeAmountInclTax;
$baseTotalWeeeAmountInclTax += $baseWeeeAmountInclTax;
$newApplied = [];
$applied = $this->_weeeData->getApplied($orderItem);
foreach ($applied as $one) {
$title = (string) $one['title'];
$one['base_row_amount'] = $creditmemo->roundPrice($one['base_row_amount'] * $ratio, $title . '_base');
$one['row_amount'] = $creditmemo->roundPrice($one['row_amount'] * $ratio, $title);
$one['base_row_amount_incl_tax'] = $creditmemo->roundPrice($one['base_row_amount_incl_tax'] * $ratio, $title . '_base');
$one['row_amount_incl_tax'] = $creditmemo->roundPrice($one['row_amount_incl_tax'] * $ratio, $title);
$newApplied[] = $one;
}
$this->_weeeData->setApplied($item, $newApplied);
// Update order item
$newApplied = [];
$applied = $this->_weeeData->getApplied($orderItem);
foreach ($applied as $one) {
if (isset($one[WeeeHelper::KEY_BASE_WEEE_AMOUNT_REFUNDED])) {
$one[WeeeHelper::KEY_BASE_WEEE_AMOUNT_REFUNDED] = $one[WeeeHelper::KEY_BASE_WEEE_AMOUNT_REFUNDED] + $baseWeeeAmountExclTax;
} else {
$one[WeeeHelper::KEY_BASE_WEEE_AMOUNT_REFUNDED] = $baseWeeeAmountExclTax;
}
if (isset($one[WeeeHelper::KEY_WEEE_AMOUNT_REFUNDED])) {
$one[WeeeHelper::KEY_WEEE_AMOUNT_REFUNDED] = $one[WeeeHelper::KEY_WEEE_AMOUNT_REFUNDED] + $weeeAmountExclTax;
} else {
$one[WeeeHelper::KEY_WEEE_AMOUNT_REFUNDED] = $weeeAmountExclTax;
}
if (isset($one[WeeeHelper::KEY_BASE_WEEE_TAX_AMOUNT_REFUNDED])) {
$one[WeeeHelper::KEY_BASE_WEEE_TAX_AMOUNT_REFUNDED] = $one[WeeeHelper::KEY_BASE_WEEE_TAX_AMOUNT_REFUNDED] + $itemBaseTaxAmount;
} else {
$one[WeeeHelper::KEY_BASE_WEEE_TAX_AMOUNT_REFUNDED] = $itemBaseTaxAmount;
}
//.........这里部分代码省略.........
示例3: df_cm_set_increment_id
/**
* 2016-08-29
* Заметил, что в новых версиях Magento в момент выполнения @see \Df\Payment\Method::refund()
* у @see \Magento\Sales\Model\Order\Creditmemo ещё отсутствует increment_id:
* он устанавливается только при сохранении объекта:
* @see \Magento\Sales\Model\ResourceModel\EntityAbstract::_beforeSave()
* https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Sales/Model/ResourceModel/EntityAbstract.php#L123-L129
* @param CM $cm
* @return void
*/
function df_cm_set_increment_id(CM $cm)
{
if (!$cm->getIncrementId()) {
$cm->setIncrementId(df_sales_seq_m()->getSequence($cm->getEntityType(), $cm->getStore()->getGroup()->getDefaultStoreId())->getNextValue());
}
}