本文整理汇总了PHP中Isotope\Isotope::getCart方法的典型用法代码示例。如果您正苦于以下问题:PHP Isotope::getCart方法的具体用法?PHP Isotope::getCart怎么用?PHP Isotope::getCart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Isotope\Isotope
的用法示例。
在下文中一共展示了Isotope::getCart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generate the checkout step
*
* @return string
*/
public function generate()
{
$objTemplate = new Template($this->objModule->iso_collectionTpl);
$objOrder = Isotope::getCart()->getDraftOrder();
$objOrder->addToTemplate($objTemplate, array('gallery' => $this->objModule->iso_gallery, 'sorting' => $objOrder->getItemsSortingCallable($this->objModule->iso_orderCollectionBy)));
return $objTemplate->parse();
}
示例2: generate
/**
* Generate the checkout step
* @return string
*/
public function generate()
{
// Make sure field data is available
\Controller::loadDataContainer('tl_iso_product_collection');
\System::loadLanguageFile('tl_iso_product_collection');
$objTemplate = new Template($this->strTemplate);
$varValue = null;
$objWidget = new FormTextArea(FormTextArea::getAttributesFromDca($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField], $this->strField, $varValue, $this->strField, $this->strTable, $this));
$objWidget->storeValues = true;
if (\Input::post('FORM_SUBMIT') == $this->strFormId) {
$objWidget->validate();
$varValue = $objWidget->value;
// Do not submit the field if there are errors
if ($objWidget->hasErrors()) {
$doNotSubmit = true;
} elseif ($objWidget->submitInput()) {
$objOrder = Isotope::getCart()->getDraftOrder();
// Store the form data
$_SESSION['FORM_DATA'][$this->strField] = $varValue;
// Set the correct empty value (see #6284, #6373)
if ($varValue === '') {
$varValue = $objWidget->getEmptyValue();
}
// Set the new value
if ($varValue !== $objOrder->{$this->strField}) {
$objOrder->{$this->strField};
}
}
}
$objTemplate->headline = $GLOBALS['TL_LANG'][$this->strTable][$this->strField][0];
$objTemplate->customerNotes = $objWidget->parse();
return $objTemplate->parse();
}
示例3: generate
/**
* Display a wildcard in the back end
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ISOTOPE ECOMMERCE: STORE CONFIG SWICHER ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
$this->iso_config_ids = deserialize($this->iso_config_ids);
if (!is_array($this->iso_config_ids) || !count($this->iso_config_ids)) {
// Can't use empty() because its an object property (using __get)
return '';
}
if (\Input::get('config') != '') {
if (in_array(\Input::get('config'), $this->iso_config_ids)) {
Isotope::getCart()->config_id = \Input::get('config');
Isotope::getCart()->save();
}
\Controller::redirect(preg_replace('@[?|&]config=' . \Input::get('config') . '@', '', \Environment::get('request')));
}
return parent::generate();
}
示例4: compile
/**
* Generate the module
*/
protected function compile()
{
$objCart = Isotope::getCart();
$objAddress = $objCart->getShippingAddress();
$this->Template->showResults = false;
$this->Template->requiresShipping = false;
// There is no address
if (!$objAddress->id) {
return;
}
$this->Template->showResults = true;
$arrMethods = array();
// Get the shipping methods
if ($objAddress->id && $objCart->requiresShipping()) {
$this->Template->requiresShipping = true;
$objShippingMethods = Shipping::findMultipleByIds($this->arrShippingMethods);
/* @var Shipping $objShipping */
foreach ($objShippingMethods as $objShipping) {
if ($objShipping->isAvailable()) {
$fltPrice = $objShipping->getPrice();
$arrMethods[] = array('label' => $objShipping->getLabel(), 'price' => $fltPrice, 'formatted_price' => Isotope::formatPriceWithCurrency($fltPrice), 'shipping' => $objShipping);
}
}
RowClass::withKey('rowClass')->addCount('row_')->addFirstLast('row_')->addEvenOdd('row_')->applyTo($arrMethods);
}
$this->Template->shippingMethods = $arrMethods;
}
示例5: addOrderCondition
/**
* Automatically add Billpay conditions to checkout form
*
* @param Form $objForm
* @param \Module $objModule
*/
public static function addOrderCondition(Form $objForm, \Module $objModule)
{
if (Isotope::getCart()->hasPayment() && Isotope::getCart()->getPaymentMethod() instanceof BillpayWithSaferpay) {
$strLabel = $GLOBALS['TL_LANG']['MSC']['billpay_agb_' . Isotope::getCart()->getBillingAddress()->country];
if ($strLabel == '') {
throw new \LogicException('Missing BillPay AGB for country "' . Isotope::getCart()->getBillingAddress()->country . '" and language "' . $GLOBALS['TL_LANGUAGE'] . '"');
}
$objForm->addFormField('billpay_confirmation', array('label' => array('', $strLabel), 'inputType' => 'checkbox', 'eval' => array('mandatory' => true)));
}
}
示例6: addToCart
/**
* Callback for add_to_cart button
*
* @param IsotopeProduct $objProduct
* @param array $arrConfig
*/
public function addToCart(IsotopeProduct $objProduct, array $arrConfig = array())
{
$objModule = $arrConfig['module'];
$intQuantity = $objModule->iso_use_quantity && intval(\Input::post('quantity_requested')) > 0 ? intval(\Input::post('quantity_requested')) : 1;
// Do not add parent of variant product to the cart
if ($objProduct->hasVariants() && !$objProduct->isVariant()) {
return;
}
if (Isotope::getCart()->addProduct($objProduct, $intQuantity, $arrConfig) !== false) {
Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['addedToCart']);
if (!$objModule->iso_addProductJumpTo) {
$this->reload();
}
\Controller::redirect(\Haste\Util\Url::addQueryString('continue=' . base64_encode(\Environment::get('request')), $objModule->iso_addProductJumpTo));
}
}
示例7: getPrice
/**
* Return calculated price for this shipping method
* @param IsotopeProductCollection
* @return float
*/
public function getPrice(IsotopeProductCollection $objCollection = null)
{
if (null === $objCollection) {
$objCollection = Isotope::getCart();
}
$strPrice = $this->arrData['price'];
if ($this->isPercentage()) {
$fltSurcharge = (double) substr($strPrice, 0, -1);
$fltPrice = $objCollection->subTotal / 100 * $fltSurcharge;
} else {
$fltPrice = (double) $strPrice;
}
//Make Call to UPS API to retrieve pricing
$fltPrice += $this->getLiveRateQuote($objCollection);
return Isotope::calculatePrice($fltPrice, $this, 'fedex', $this->arrData['tax_class']);
}
示例8: generate
/**
* Generate the checkout step
* @return string
*/
public function generate()
{
$objTemplate = new Template($this->strTemplate);
$arrAttributes = ['dateDirection' => 'gtToday', 'inputType' => 'calendar', 'eval' => ['required' => true, 'rgxp' => 'date', 'datepicker' => true]];
$varValue = null;
$objWidget = new FormCalendarField(FormCalendarField::getAttributesFromDca($arrAttributes, $this->strField, $varValue, $this->strField, $this->strTable, $this));
$objWidget->storeValues = true;
if (\Input::post('FORM_SUBMIT') == $this->strFormId) {
$objWidget->validate();
$varValue = $objWidget->value;
$rgxp = $arrAttributes['eval']['rgxp'];
// Convert date formats into timestamps (check the eval setting first -> #3063)
if ($varValue != '' && in_array($rgxp, array('date', 'time', 'datim'))) {
try {
$objDate = new \Date($varValue, \Date::getFormatFromRgxp($rgxp));
$varValue = $objDate->tstamp;
} catch (\OutOfBoundsException $e) {
$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue));
}
}
// Do not submit the field if there are errors
if ($objWidget->hasErrors()) {
$doNotSubmit = true;
} elseif ($objWidget->submitInput()) {
$objOrder = Isotope::getCart()->getDraftOrder();
// Store the form data
$_SESSION['FORM_DATA'][$this->strField] = $varValue;
// Set the correct empty value (see #6284, #6373)
if ($varValue === '') {
$varValue = $objWidget->getEmptyValue();
}
// Set the new value
if ($varValue !== $objOrder->{$this->strField}) {
$objOrder->{$this->strField};
}
}
}
$objTemplate->headline = $GLOBALS['TL_LANG'][$this->strTable]['date_picker'][0];
$objTemplate->datePicker = $objWidget->parse();
return $objTemplate->parse();
}
示例9: calculateGrossPrice
/**
* Calculate a price, add all applicable taxes
* @param float
* @param array|null
* @return float
*/
public function calculateGrossPrice($fltPrice, $arrAddresses = null)
{
if (!is_array($arrAddresses)) {
$arrAddresses = array('billing' => Isotope::getCart()->getBillingAddress(), 'shipping' => Isotope::getCart()->getShippingAddress());
}
/** @var \Isotope\Model\TaxRate $objIncludes */
if (($objIncludes = $this->getRelated('includes')) !== null && !$objIncludes->isApplicable($fltPrice, $arrAddresses)) {
$fltPrice -= $objIncludes->calculateAmountIncludedInPrice($fltPrice);
}
if (($objRates = $this->getRelated('rates')) !== null) {
/** @var \Isotope\Model\TaxRate $objTaxRate */
foreach ($objRates as $objTaxRate) {
if ($objTaxRate->isApplicable($fltPrice, $arrAddresses)) {
$fltPrice += $objTaxRate->calculateAmountAddedToPrice($fltPrice);
if ($objTaxRate->stop) {
break;
}
}
}
}
return $fltPrice;
}
示例10: getPrice
/**
* Return calculated price for this shipping method
* @return float
*/
public function getPrice(IsotopeProductCollection $objCollection = null)
{
if (null === $objCollection) {
$objCollection = Isotope::getCart();
}
if ($this->isPercentage()) {
$fltPrice = $objCollection->getSubtotal() / 100 * $this->getPercentage();
} else {
$fltPrice = (double) $this->arrData['price'];
}
if ($this->flatCalculation == 'perProduct' || $this->flatCalculation == 'perItem') {
$arrItems = $objCollection->getItems();
$intMultiplier = 0;
foreach ($arrItems as $objItem) {
if (!$objItem->hasProduct() || $objItem->getProduct()->isExemptFromShipping()) {
continue;
}
$intMultiplier += $this->flatCalculation == 'perProduct' ? 1 : $objItem->quantity;
}
$fltPrice = $fltPrice * $intMultiplier;
}
return Isotope::calculatePrice($fltPrice, $this, 'price', $this->arrData['tax_class']);
}
示例11: 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);
}
示例12: getPrice
/**
* Return calculated price for this shipping method
* @return float
*/
public function getPrice(IsotopeProductCollection $objCollection = null)
{
if (null === $objCollection) {
$objCollection = Isotope::getCart();
}
if ($this->or_pricing == '1') {
$fltAltPrice = $objCollection->subTotal - $objCollection->subTotal / (1 + floatval($this->alternative_price) / 100);
switch ($this->alternative_price_logic) {
case '1':
//less
$fltPrice = $this->arrData['price'] < $fltAltPrice ? $this->arrData['price'] : $fltAltPrice;
break;
case '2':
//greater
$fltPrice = $this->arrData['price'] > $fltAltPrice ? $this->arrData['price'] : $fltAltPrice;
break;
}
return $fltPrice;
} else {
return $this->arrData['price'];
}
return Isotope::calculatePrice($fltPrice, $this, 'price', $this->arrData['tax_class']);
}
示例13: complete
/**
* Complete order if the checkout has been made. This will cleanup session data
*
* @return bool
*/
public function complete()
{
if ($this->isCheckoutComplete()) {
unset($_SESSION['FORM_DATA']);
unset($_SESSION['FILES']);
// Retain custom config ID
if (($objCart = Isotope::getCart()) !== null && $objCart->config_id != $this->config_id) {
$objCart->config_id = $this->config_id;
}
return true;
}
return false;
}
示例14: createForMember
/**
* Create a new address for a member and automatically set default properties
* @param int
* @param array|null
* @return Address
*/
public static function createForMember($intMember, $arrFill = null)
{
$objAddress = new Address();
$arrData = array('pid' => $intMember, 'ptable' => 'tl_member', 'tstamp' => time(), 'store_id' => Isotope::getCart()->store_id);
if (!empty($arrFill) && is_array($arrFill) && ($objMember = \MemberModel::findByPk($intMember)) !== null) {
$arrData = array_intersect_key(array_merge($objMember->row(), $arrData, array('street_1' => $objMember->street, 'subdivision' => strtoupper($objMember->country . '-' . $objMember->state))), array_flip($arrFill));
}
$objAddress->setRow($arrData);
return $objAddress;
}
示例15: createForMember
/**
* Create a new address for a member and automatically set default properties
*
* @param int $intMember
* @param array|null $arrFill
*
* @return static
*/
public static function createForMember($intMember, $arrFill = null)
{
$objAddress = new static();
$arrData = array('pid' => $intMember, 'ptable' => 'tl_member', 'tstamp' => time(), 'store_id' => (int) Isotope::getCart()->store_id);
if (!empty($arrFill) && is_array($arrFill) && ($objMember = \MemberModel::findByPk($intMember)) !== null) {
// Generate address data from tl_member, limit to fields enabled in the shop configuration
$arrMember = array_intersect_key(array_merge($objMember->row(), array('street_1' => $objMember->street, 'subdivision' => strtoupper($objMember->country . '-' . $objMember->state))), array_flip($arrFill));
$arrData = array_merge($arrMember, $arrData);
}
$objAddress->setRow($arrData);
return $objAddress;
}