本文整理汇总了PHP中Axis_Locale::getNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP Axis_Locale::getNumber方法的具体用法?PHP Axis_Locale::getNumber怎么用?PHP Axis_Locale::getNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Axis_Locale
的用法示例。
在下文中一共展示了Axis_Locale::getNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
*
* @param array $data
* @return Axis_Db_Table_Row
*/
public function save(array $data)
{
$row = $this->getRow($data);
//before save
$row->rate = Axis_Locale::getNumber($row->rate);
if ($row->code === Axis::config('locale/main/currency') && $row->rate != 1) {
// throw new Axis_Exception(
Axis::message()->addError(Axis::translate('locale')->__('Base currency rate should be 1.00'));
$row->rate = 1;
}
if (empty($row->format)) {
$row->format = new Zend_Db_Expr('NULL');
}
//end before save
$row->save();
return $row;
}
示例2: add
/**
* Add new product or product variation to shopping cart
*
* @param int $productId
* @param array $modifierOptions
* @param array $variationOptions
* @param array $quantity [optional]
* @return mixed int|bool
*/
public function add($productId, $modifierOptions, $variationOptions, $quantity = false)
{
$product = Axis::single('catalog/product')->find($productId)->current();
if (!$product instanceof Axis_Catalog_Model_Product_Row) {
Axis::message()->addError(Axis::translate('catalog')->__('Product not found'));
return false;
}
$stockRow = $product->getStockRow();
if (!$quantity) {
$quantity = $stockRow->min_qty_allowed ? $stockRow->min_qty_allowed : 1;
}
if (!$stockRow->decimal) {
$quantity = floor($quantity);
}
$shoppingCartProductRow = array('shopping_cart_id' => $this->getCartId(), 'product_id' => $productId, 'quantity' => $quantity, 'final_price' => 0, 'final_weight' => 0, 'variation_id' => 0);
$variationId = $product->getVariationIdByVariationOptions($variationOptions);
if (false === $variationId) {
Axis::message()->addError(Axis::translate('checkout')->__('Fill all variation options please'));
return false;
}
$shoppingCartProductRow['variation_id'] = $variationId;
if (!$stockRow->canAddToCart($quantity, $variationId)) {
return false;
}
$modifierAttributes = Axis::single('catalog/product_attribute')->getAttributesByModifiers($product->id, $modifierOptions);
if (false === $modifierAttributes) {
return false;
}
$variationAttributes = Axis::single('catalog/product_attribute')->getAttributesByVariation($variationId, $variationOptions);
if (false === $variationAttributes) {
return false;
}
$attributes = $modifierAttributes + $variationAttributes;
Axis::message()->addSuccess(Axis::translate('checkout')->__('Product was successfully added to your shopping cart'));
// Check for clon exists
if (false !== ($clon = $this->_getClon($productId, $attributes))) {
$this->updateItem($clon['id'], $clon['quantity'] + Axis_Locale::getNumber($quantity));
return true;
}
// Insert product
$shoppingCartProductRow['final_price'] = $product->getPrice(array_keys($attributes));
$shoppingCartProductRow['final_weight'] = $product->getWeight(array_keys($attributes));
$shoppingCartProductId = Axis::single('checkout/cart_product')->insert($shoppingCartProductRow);
// Insert attributes for this product
$modelCartAttribute = Axis::single('checkout/cart_product_attribute');
foreach ($attributes as $attributeId => $attributeValue) {
$modelCartAttribute->insert(array('shopping_cart_product_id' => $shoppingCartProductId, 'product_attribute_id' => $attributeId, 'product_attribute_value' => $attributeValue));
}
Axis::dispatch('checkout_cart_add_product_success', array('product' => $product, 'attributes' => $attributes, 'quantity' => $quantity, 'cart_product_id' => $shoppingCartProductId));
return $shoppingCartProductId;
}
示例3: _prepareDataForTable
/**
* Prepare data for table before save
*
* @param array $data
* @return array
*/
protected function _prepareDataForTable($data)
{
foreach ($this->info(self::METADATA) as $name => $values) {
if (!isset($data[$name]) || $data[$name] instanceof Zend_Db_Expr) {
continue;
}
if ('decimal' == $values['DATA_TYPE']) {
$data[$name] = Axis_Locale::getNumber($data[$name]);
}
}
return $data;
}