本文整理汇总了PHP中Isotope\Isotope::roundPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Isotope::roundPrice方法的具体用法?PHP Isotope::roundPrice怎么用?PHP Isotope::roundPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Isotope\Isotope
的用法示例。
在下文中一共展示了Isotope::roundPrice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareFISParams
/**
* Prepare FIS params
* @param Order
* @return array
*/
private function prepareFISParams($objOrder)
{
$objBillingAddress = $objOrder->getBillingAddress();
$objShippingAddress = $objOrder->getShippingAddress();
$arrInvoice = array('ECOM_BILLTO_POSTAL_NAME_FIRST' => substr($objBillingAddress->firstname, 0, 50), 'ECOM_BILLTO_POSTAL_NAME_LAST' => substr($objBillingAddress->lastname, 0, 50), 'ECOM_SHIPTO_POSTAL_STREET_LINE1' => $objShippingAddress->street_1, 'ECOM_SHIPTO_POSTAL_POSTALCODE' => $objShippingAddress->postal, 'ECOM_SHIPTO_POSTAL_CITY' => $objShippingAddress->city, 'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => strtoupper($objShippingAddress->country), 'ECOM_SHIPTO_DOB' => date('d/m/Y', $objShippingAddress->dateOfBirth), 'REF_CUSTOMERID' => substr('psp_' . $this->id . '_' . $objOrder->id . '_' . $objOrder->uniqid, 0, 17), 'ECOM_CONSUMER_GENDER' => $objBillingAddress->gender == 'male' ? 'M' : 'F');
$arrOrder = array();
$i = 1;
// Need to take the items from the cart as they're not transferred to the order here yet
foreach (Isotope::getCart()->getItems() as $objItem) {
$objPrice = $objItem->getProduct()->getPrice();
$fltVat = Isotope::roundPrice(100 / $objPrice->getNetAmount() * $objPrice->getGrossAmount() - 100, false);
$arrOrder['ITEMID' . $i] = $objItem->id;
$arrOrder['ITEMNAME' . $i] = substr($objItem->getName(), 40);
$arrOrder['ITEMPRICE' . $i] = $objPrice->getNetAmount();
$arrOrder['ITEMQUANT' . $i] = $objItem->quantity;
$arrOrder['ITEMVATCODE' . $i] = $fltVat . '%';
$arrOrder['ITEMVAT' . $i] = Isotope::roundPrice($objPrice->getGrossAmount() - $objPrice->getNetAmount(), false);
$arrOrder['FACEXCL' . $i] = $objPrice->getNetAmount();
$arrOrder['FACTOTAL' . $i] = $objPrice->getGrossAmount();
++$i;
}
return array_merge($arrInvoice, $arrOrder);
}
示例2: getTaxFreeTotal
/**
* Sum tax free total of items and surcharges
* @return float
*/
public function getTaxFreeTotal()
{
if ($this->isLocked()) {
return $this->tax_free_total;
}
if (!isset($this->arrCache['taxFreeTotal'])) {
$fltAmount = $this->getTaxFreeSubtotal();
$arrSurcharges = $this->getSurcharges();
foreach ($arrSurcharges as $objSurcharge) {
if ($objSurcharge->addToTotal) {
$fltAmount += $objSurcharge->tax_free_total_price;
}
}
$this->arrCache['taxFreeTotal'] = $fltAmount > 0 ? Isotope::roundPrice($fltAmount) : 0;
}
return $this->arrCache['taxFreeTotal'];
}
示例3: findForCollection
/**
* Generate surhcharges for a collection
* @param IsotopeProductCollection
* @return array
*/
public static function findForCollection(IsotopeProductCollection $objCollection)
{
$arrPreTax = array();
$arrPostTax = array();
// !HOOK: get collection surcharges
if (isset($GLOBALS['ISO_HOOKS']['findSurchargesForCollection']) && is_array($GLOBALS['ISO_HOOKS']['findSurchargesForCollection'])) {
foreach ($GLOBALS['ISO_HOOKS']['findSurchargesForCollection'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$arrResult = $objCallback->{$callback[1]}($objCollection);
foreach ($arrResult as $objSurcharge) {
if (!$objSurcharge instanceof IsotopeProductCollectionSurcharge || $objSurcharge instanceof Tax) {
throw new \InvalidArgumentException('Instance of ' . get_class($objSurcharge) . ' is not a valid product collection surcharge.');
}
if ($objSurcharge->hasTax()) {
$arrPreTax[] = $objSurcharge;
} else {
$arrPostTax[] = $objSurcharge;
}
}
}
}
/** @var \Isotope\Model\ProductCollection\Order $objCollection */
/** @var Tax[] $arrTaxes */
$arrTaxes = array();
$arrAddresses = array('billing' => $objCollection->getBillingAddress(), 'shipping' => $objCollection->getShippingAddress());
foreach ($objCollection->getItems() as $objItem) {
// This should never happen, but we can't calculate it
if (!$objItem->hasProduct()) {
continue;
}
$objProduct = $objItem->getProduct();
/** @var \Isotope\Model\TaxClass $objTaxClass */
$objTaxClass = $objProduct->getPrice() ? $objProduct->getPrice()->getRelated('tax_class') : null;
// Skip products without tax class
if (null === $objTaxClass) {
continue;
}
$arrTaxIds = array();
$fltPrice = $objItem->getTotalPrice();
/** @var \Isotope\Model\ProductCollectionSurcharge $objSurcharge */
foreach ($arrPreTax as $objSurcharge) {
$fltPrice += $objSurcharge->getAmountForCollectionItem($objItem);
}
/** @var \Isotope\Model\TaxRate $objIncludes */
if (($objIncludes = $objTaxClass->getRelated('includes')) !== null) {
if ($objIncludes->isApplicable($fltPrice, $arrAddresses)) {
$fltTax = $objIncludes->calculateAmountIncludedInPrice($fltPrice);
if (!isset($arrTaxes[$objTaxClass->id . '_' . $objIncludes->id])) {
$arrTaxes[$objTaxClass->id . '_' . $objIncludes->id] = new Tax();
$arrTaxes[$objTaxClass->id . '_' . $objIncludes->id]->label = $objTaxClass->getLabel() ?: $objIncludes->getLabel();
$arrTaxes[$objTaxClass->id . '_' . $objIncludes->id]->price = $objIncludes->getAmount() . ($objIncludes->isPercentage() ? '%' : '');
$arrTaxes[$objTaxClass->id . '_' . $objIncludes->id]->total_price = Isotope::roundPrice($fltTax, $objTaxClass->applyRoundingIncrement);
$arrTaxes[$objTaxClass->id . '_' . $objIncludes->id]->addToTotal = false;
} else {
$arrTaxes[$objTaxClass->id . '_' . $objIncludes->id]->total_price = Isotope::roundPrice($arrTaxes[$objTaxClass->id . '_' . $objIncludes->id]->total_price + $fltTax, $objTaxClass->applyRoundingIncrement);
if (is_numeric($arrTaxes[$objTaxClass->id . '_' . $objIncludes->id]->price) && is_numeric($objIncludes->getAmount())) {
$arrTaxes[$objTaxClass->id . '_' . $objIncludes->id]->price += $objIncludes->getAmount();
}
}
$taxId = array_search($objTaxClass->id . '_' . $objIncludes->id, array_keys($arrTaxes)) + 1;
$arrTaxes[$objTaxClass->id . '_' . $objIncludes->id]->addTaxNumber($taxId);
$arrTaxIds[] = $taxId;
}
}
if (($objRates = $objTaxClass->getRelated('rates')) !== null) {
/** @var \Isotope\Model\TaxRate $objTaxRate */
foreach ($objRates as $objTaxRate) {
if ($objTaxRate->isApplicable($fltPrice, $arrAddresses)) {
$fltTax = $objTaxRate->calculateAmountAddedToPrice($fltPrice);
if (!isset($arrTaxes[$objTaxRate->id])) {
$arrTaxes[$objTaxRate->id] = new Tax();
$arrTaxes[$objTaxRate->id]->label = $objTaxRate->getLabel();
$arrTaxes[$objTaxRate->id]->price = $objTaxRate->getAmount() . ($objTaxRate->isPercentage() ? '%' : '');
$arrTaxes[$objTaxRate->id]->total_price = Isotope::roundPrice($fltTax, $objTaxClass->applyRoundingIncrement);
$arrTaxes[$objTaxRate->id]->addToTotal = true;
} else {
$arrTaxes[$objTaxRate->id]->total_price = Isotope::roundPrice($arrTaxes[$objTaxRate->id]->total_price + $fltTax, $objTaxClass->applyRoundingIncrement);
if (is_numeric($arrTaxes[$objTaxRate->id]->price) && is_numeric($objTaxRate->getAmount())) {
$arrTaxes[$objTaxRate->id]->price += $objTaxRate->getAmount();
}
}
$taxId = array_search($objTaxRate->id, array_keys($arrTaxes)) + 1;
$arrTaxes[$objTaxRate->id]->addTaxNumber($taxId);
$arrTaxIds[] = $taxId;
if ($objTaxRate->stop) {
break;
}
}
}
}
$strTaxId = implode(',', $arrTaxIds);
if ($objItem->tax_id != $strTaxId) {
$objCollection->updateItem($objItem, array('tax_id' => $strTaxId));
}
foreach ($arrPreTax as $objSurcharge) {
//.........这里部分代码省略.........