本文整理汇总了PHP中Price::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Price::create方法的具体用法?PHP Price::create怎么用?PHP Price::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Price
的用法示例。
在下文中一共展示了Price::create方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
Price::create(['min' => '0', 'max' => '1000000']);
Price::create(['min' => '1000000', 'max' => '10000000']);
Price::create(['min' => '10000000', 'max' => '100000000']);
Price::create(['min' => '100000000']);
}
示例2: __construct
public function __construct($controller, $name, $quantity = null, $redirectURL = null)
{
parent::__construct($controller, $name, FieldList::create(), FieldList::create(), null);
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript('swipestripe/javascript/ProductForm.js');
$this->product = $controller->data();
$this->quantity = $quantity;
$this->redirectURL = $redirectURL;
$this->fields = $this->createFields();
$this->actions = $this->createActions();
$this->validator = $this->createValidator();
$this->setupFormErrors();
$this->addExtraClass('product-form');
//Add a map of all variations and prices to the page for updating the price
$map = array();
$variations = $this->product->Variations();
$productPrice = $this->product->Price();
if ($variations && $variations->exists()) {
foreach ($variations as $variation) {
if ($variation->isEnabled()) {
$variationPrice = $variation->Price();
$amount = Price::create();
$amount->setAmount($productPrice->getAmount() + $variationPrice->getAmount());
$amount->setCurrency($productPrice->getCurrency());
$amount->setSymbol($productPrice->getSymbol());
$map[] = array('price' => $amount->Nice(), 'options' => $variation->Options()->column('ID'), 'free' => _t('Product.FREE', 'Free'));
}
}
}
$this->setAttribute('data-map', json_encode($map));
}
示例3: Amount
public function Amount()
{
// TODO: Multi currency
$order = $this->Order();
$amount = Price::create();
$amount->setAmount($this->Price);
$amount->setCurrency($order->BaseCurrency);
$amount->setSymbol($order->BaseCurrencySymbol);
return $amount;
}
示例4: Amount
public function Amount()
{
$amount = Price::create();
$amount->setCurrency($this->Currency);
$amount->setAmount($this->Price);
$amount->setSymbol(ShopConfig::current_shop_config()->BaseCurrencySymbol);
//Transform amount for applying discounts etc.
$this->extend('updateAmount', $amount);
return $amount;
}
示例5: getFormFields
/**
* Add shipping region code dropdown to form.
* @return FieldList
*/
public function getFormFields()
{
$fields = new FieldList();
$field = new StreakGST_ModifierField($this, self::description());
/** @var Price $price */
$price = Price::create();
$price->setAmount($this->GST);
$field->setAmount($price);
$fields->push($field);
return $fields;
}
示例6: run
public function run()
{
Price::create(['price_id' => 1, 'low_price' => 0, 'high_price' => 50]);
Price::create(['price_id' => 2, 'low_price' => 50, 'high_price' => 100]);
Price::create(['price_id' => 3, 'low_price' => 100, 'high_price' => 300]);
Price::create(['price_id' => 4, 'low_price' => 300, 'high_price' => 500]);
Price::create(['price_id' => 5, 'low_price' => 500, 'high_price' => 1000]);
Price::create(['price_id' => 1, 'low_price' => 0, 'high_price' => 50]);
Price::create(['price_id' => 2, 'low_price' => 50, 'high_price' => 100]);
Price::create(['price_id' => 3, 'low_price' => 100, 'high_price' => 300]);
Price::create(['price_id' => 4, 'low_price' => 300, 'high_price' => 500]);
Price::create(['price_id' => 5, 'low_price' => 500, 'high_price' => 1000]);
Price::create(['price_id' => 5, 'low_price' => 500, 'high_price' => 1000]);
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$rules = array('min' => 'required|integer|min:0', 'max' => 'integer|min:0');
$input = Input::except('_token');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return Redirect::action('PriceController@create')->withErrors($validator);
} else {
if ($input['max'] == '') {
$input['max'] = NULL;
}
$id = Price::create($input)->id;
return Redirect::action('PriceController@index');
}
}
示例8: getFormFields
/**
* Add shipping region code dropdown to form.
* @return FieldList
*/
public function getFormFields()
{
$fields = new FieldList();
if ($shippingRegion = $this->Region()) {
$field = new StreakRegionShippingModifierField($this, $this->Description, $shippingRegion->ID);
/** @var Price $price */
$price = Price::create();
$price->setAmount($this->Price);
$field->setAmount($price);
$fields->push($field);
}
if (!$fields->exists()) {
Requirements::javascript('swipestreak-regionalshipping/javascript/RegionalShippingModifierField.js');
}
return $fields;
}
示例9: Product
require_once "DataBase/Priceset.php";
require_once "DataBase/Group.php";
require_once "DataBase/Price.php";
$db_action = var_get_post("db_action", "");
$product = new Product();
$tax = new Tax();
$category = new Category();
$priceset = new Priceset();
$price = new Price();
$group = new Group();
switch ($db_action) {
case "new":
$product->create(var_post("product_id", ""), array(var_post("name", ""), var_post("details", ""), var_post("category_id", ""), var_post("tax_id", ""), var_post("available", ""), var_post("group_id", ""), var_post("order_number", ""), var_post("anmerkung", "")));
$priceset_list = $priceset->get();
for ($i = 0; $i < count($priceset_list); $i++) {
$price->create(var_post("priceset_id_" . $i, ""), var_post("product_id", ""), array(var_post("priceset_price_" . $i, "")));
}
break;
case "edit":
$product->update(var_post("product_id", ""), array(var_post("name", ""), var_post("details", ""), var_post("category_id", ""), var_post("tax_id", ""), var_post("available", ""), var_post("group_id", ""), var_post("order_number", ""), var_post("anmerkung", "")));
$priceset_list = $priceset->get();
for ($i = 0; $i < count($priceset_list); $i++) {
if ($price->exists(var_post("priceset_id_" . $i, ""), var_post("product_id", ""))) {
$price->update(var_post("priceset_id_" . $i, ""), var_post("product_id", ""), array(var_post("priceset_price_" . $i, "")));
} else {
$price->create(var_post("priceset_id_" . $i, ""), var_post("product_id", ""), array(var_post("priceset_price_" . $i, "")));
}
}
break;
case "delete":
$product->delete(var_get("product_id", ""));
示例10: TotalPaid
/**
* Calculate the total paid for this order, only 'Success' payments
* are considered.
*
* @return Price With value and currency of total paid
*/
public function TotalPaid()
{
$paid = 0;
if ($this->Payments()) {
foreach ($this->Payments() as $payment) {
if ($payment->Status == 'Success') {
$paid += $payment->Amount->getAmount();
}
}
}
$totalPaid = Price::create();
$totalPaid->setAmount($paid);
$totalPaid->setCurrency($this->BaseCurrency);
$totalPaid->setSymbol($this->BaseCurrencySymbol);
return $totalPaid;
}
示例11: testAddProductToCartChangePrice
/**
* Change product price after it is in the cart, check that price has not changed in cart
*/
public function testAddProductToCartChangePrice()
{
$productA = $this->objFromFixture('Product', 'productA');
$this->logInAs('admin');
$productA->doPublish();
$this->logOut();
$this->get(Director::makeRelative($productA->Link()));
$this->submitForm('ProductForm_ProductForm', null, array('Quantity' => 1));
$order = Cart::get_current_order();
$items = $order->Items();
$firstItem = $items->First();
$this->assertEquals(1, $order->Items()->Count());
$this->assertEquals($productA->Price, $firstItem->Price);
$newAmount = Price::create();
$newAmount->setAmount(72.34);
$newAmount->setCurrency('NZD');
DataObject::flush_and_destroy_cache();
$this->logInAs('admin');
$productA->Price = $newAmount->getAmount();
$productA->doPublish();
$this->logOut();
$this->get(Director::makeRelative($productA->Link()));
$this->submitForm('ProductForm_ProductForm', null, array('Quantity' => 1));
$order = Cart::get_current_order();
$items = $order->Items();
$firstItem = $items->First();
$secondItem = $items->Last();
$this->assertEquals(2, $order->Items()->Count());
$this->assertTrue(in_array(500, $order->Items()->column('Price')));
$this->assertTrue(in_array(72.34, $order->Items()->column('Price')));
}
示例12: create
/**
* @param float $value
* @param string $currency
* @return OptionalPrice
*/
public static function create($value = null, $currency = null)
{
return parent::create($value, $currency);
}