本文整理汇总了PHP中Isotope\Isotope::formatOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Isotope::formatOptions方法的具体用法?PHP Isotope::formatOptions怎么用?PHP Isotope::formatOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Isotope\Isotope
的用法示例。
在下文中一共展示了Isotope::formatOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trackGATransaction
/**
* Actually execute the GoogleAnalytics tracking
* @param Database_Result
* @param IsotopeProductCollection
*/
protected function trackGATransaction($objConfig, $objOrder)
{
// Initilize GA Tracker
$tracker = new \UnitedPrototype\GoogleAnalytics\Tracker($objConfig->ga_account, \Environment::get('base'));
// Assemble Visitor information
// (could also get unserialized from database)
$visitor = new \UnitedPrototype\GoogleAnalytics\Visitor();
$visitor->setIpAddress(\Environment::get('ip'));
$visitor->setUserAgent(\Environment::get('httpUserAgent'));
$transaction = new \UnitedPrototype\GoogleAnalytics\Transaction();
$transaction->setOrderId($objOrder->order_id);
$transaction->setAffiliation($objConfig->name);
$transaction->setTotal($objOrder->getTotal());
$transaction->setTax($objOrder->getTotal() - $objOrder->getTaxFreeTotal());
// $transaction->setShipping($objOrder->shippingTotal);
$objAddress = $objOrder->getBillingAddress();
$transaction->setCity($objAddress->city);
if ($objAddress->subdivision) {
$arrSub = explode("-", $objAddress->subdivision, 2);
$transaction->setRegion($arrSub[1]);
}
$transaction->setCountry($objAddress->country);
/** @var \Isotope\Model\ProductCollectionItem $objItem */
foreach ($objOrder->getItems() as $objItem) {
$item = new \UnitedPrototype\GoogleAnalytics\Item();
if ($objItem->getSku()) {
$item->setSku($objItem->getSku());
} else {
$item->setSku('product' . $objItem->product_id);
}
$item->setName($objItem->getName());
$item->setPrice($objItem->getPrice());
$item->setQuantity($objItem->quantity);
$arrOptionValues = array();
foreach (Isotope::formatOptions($objItem->getOptions()) as $option) {
$arrOptionValues[] = $option['value'];
}
if (!empty($arrOptionValues)) {
$item->setVariation(implode(', ', $arrOptionValues));
}
$transaction->addItem($item);
}
// Track logged-in member as custom variable
if ($objConfig->ga_member != '' && $objOrder->member > 0 && ($objMember = \MemberModel::findByPk($objOrder->member)) !== null) {
$customVar = new \UnitedPrototype\GoogleAnalytics\CustomVariable(1, 'Member', $this->parseSimpleTokens($objConfig->ga_member, $objMember->row()), \UnitedPrototype\GoogleAnalytics\CustomVariable::SCOPE_VISITOR);
$tracker->addCustomVariable($customVar);
}
// Assemble Session information
// (could also get unserialized from PHP session)
$session = new \UnitedPrototype\GoogleAnalytics\Session();
$tracker->trackTransaction($transaction, $session, $visitor);
}
示例2: checkoutForm
/**
* HTML form for checkout
* @param IsotopeProductCollection The order being places
* @param Module The checkout module instance
* @return mixed
*/
public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule)
{
$i = 0;
$arrData = array('aid' => $this->payone_aid, 'portalid' => $this->payone_portalid, 'mode' => $this->debug ? 'test' : 'live', 'request' => $this->trans_type == 'auth' ? 'preauthorization' : 'authorization', 'encoding' => 'UTF-8', 'clearingtype' => $this->payone_clearingtype, 'reference' => $objOrder->id, 'display_name' => 'no', 'display_address' => 'no', 'successurl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'backurl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'amount' => $objOrder->getTotal() * 100, 'currency' => $objOrder->currency, 'param' => 'paymentMethodPayone' . $this->id);
foreach ($objOrder->getItems() as $objItem) {
// Set the active product for insert tags replacement
if ($objItem->hasProduct()) {
Product::setActive($objItem->getProduct());
}
$strOptions = '';
$arrOptions = Isotope::formatOptions($objItem->getOptions());
Product::unsetActive();
if (!empty($arrOptions)) {
array_walk($arrOptions, function (&$option) {
$option = $option['label'] . ': ' . $option['value'];
});
$strOptions = ' (' . implode(', ', $arrOptions) . ')';
}
$arrData['id[' . ++$i . ']'] = $objItem->getSku();
$arrData['pr[' . $i . ']'] = round($objItem->getPrice(), 2) * 100;
$arrData['no[' . $i . ']'] = $objItem->quantity;
$arrData['de[' . $i . ']'] = specialchars($objItem->getName() . $strOptions);
}
foreach ($objOrder->getSurcharges() as $k => $objSurcharge) {
if (!$objSurcharge->addToTotal) {
continue;
}
$arrData['id[' . ++$i . ']'] = 'surcharge' . $k;
$arrData['pr[' . $i . ']'] = $objSurcharge->total_price * 100;
$arrData['no[' . $i . ']'] = '1';
$arrData['de[' . $i . ']'] = $objSurcharge->label;
}
ksort($arrData);
// Do not urlencode values because Payone does not properly decode POST values (whatever...)
$strHash = md5(implode('', $arrData) . $this->payone_key);
$objTemplate = new \Isotope\Template('iso_payment_payone');
$objTemplate->id = $this->id;
$objTemplate->data = $arrData;
$objTemplate->hash = $strHash;
$objTemplate->billing_address = $objOrder->getBillingAddress()->row();
$objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0];
$objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1];
$objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]);
return $objTemplate->parse();
}
示例3: generateItem
/**
* Generate item array for template
* @param ProductCollectionItem
* @return array
*/
protected function generateItem(ProductCollectionItem $objItem)
{
$blnHasProduct = $objItem->hasProduct();
$objProduct = $objItem->getProduct();
// Set the active product for insert tags replacement
if ($blnHasProduct) {
Product::setActive($objProduct);
}
$arrCSS = $blnHasProduct ? deserialize($objProduct->cssID, true) : array();
$arrItem = array('id' => $objItem->id, 'sku' => $objItem->getSku(), 'name' => $objItem->getName(), 'options' => Isotope::formatOptions($objItem->getOptions()), 'quantity' => $objItem->quantity, 'price' => Isotope::formatPriceWithCurrency($objItem->getPrice()), 'tax_free_price' => Isotope::formatPriceWithCurrency($objItem->getTaxFreePrice()), 'total' => Isotope::formatPriceWithCurrency($objItem->getTotalPrice()), 'tax_free_total' => Isotope::formatPriceWithCurrency($objItem->getTaxFreeTotalPrice()), 'tax_id' => $objItem->tax_id, 'href' => false, 'hasProduct' => $blnHasProduct, 'product' => $objProduct, 'item' => $objItem, 'raw' => $objItem->row(), 'rowClass' => trim('product ' . ($blnHasProduct && $objProduct->isNew() ? 'new ' : '') . $arrCSS[1]));
if (null !== $objItem->getRelated('jumpTo') && $blnHasProduct && $objProduct->isAvailableInFrontend()) {
$arrItem['href'] = $objProduct->generateUrl($objItem->getRelated('jumpTo'));
}
Product::unsetActive();
return $arrItem;
}
示例4: checkoutForm
/**
* Return the PayPal form.
* @param IsotopeProductCollection The order being places
* @param Module The checkout module instance
* @return string
*/
public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule)
{
$arrData = array();
$fltDiscount = 0;
$i = 0;
foreach ($objOrder->getItems() as $objItem) {
// Set the active product for insert tags replacement
if ($objItem->hasProduct()) {
Product::setActive($objItem->getProduct());
}
$strOptions = '';
$arrOptions = Isotope::formatOptions($objItem->getOptions());
Product::unsetActive();
if (!empty($arrOptions)) {
array_walk($arrOptions, function (&$option) {
$option = $option['label'] . ': ' . $option['value'];
});
$strOptions = ' (' . implode(', ', $arrOptions) . ')';
}
$arrData['item_number_' . ++$i] = $objItem->getSku();
$arrData['item_name_' . $i] = $objItem->getName() . $strOptions;
$arrData['amount_' . $i] = $objItem->getPrice();
$arrData['quantity_' . $i] = $objItem->quantity;
}
foreach ($objOrder->getSurcharges() as $objSurcharge) {
if (!$objSurcharge->addToTotal) {
continue;
}
// PayPal does only support one single discount item
if ($objSurcharge->total_price < 0) {
$fltDiscount -= $objSurcharge->total_price;
continue;
}
$arrData['item_name_' . ++$i] = $objSurcharge->label;
$arrData['amount_' . $i] = $objSurcharge->total_price;
}
$objTemplate = new \Isotope\Template('iso_payment_paypal');
$objTemplate->setData($this->arrData);
$objTemplate->id = $this->id;
$objTemplate->action = 'https://www.' . ($this->debug ? 'sandbox.' : '') . 'paypal.com/cgi-bin/webscr';
$objTemplate->invoice = $objOrder->id;
$objTemplate->data = array_map('specialchars', $arrData);
$objTemplate->discount = $fltDiscount;
$objTemplate->address = $objOrder->getBillingAddress();
$objTemplate->currency = $objOrder->currency;
$objTemplate->return = \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder);
$objTemplate->cancel_return = \Environment::get('base') . $objModule->generateUrlForStep('failed');
$objTemplate->notify_url = \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id;
$objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0];
$objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1];
$objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]);
return $objTemplate->parse();
}