Php – displaying lowest starting from product price on opencart – Stack Overflow bitcoin value in dollars

Instead of having a base price on the product and displaying that I want to set the base price as 0.00 and display the lowest costing option price i.E

Polo shirt price = 0

Small = £10

Medium = £15

Large = £20

And it should display starting from £10

Currently on the product page it displays price as 0 until and option is selected

I want it to do something like this but i am unsure of the syntax

Is this somewhere along the right lines? Currently it doesn’t display anything with the above code

Model public function getproductoptions($product id) {

$product option data = array();

$product option query = $this->db->query(SELECT * FROM . DB PREFIX . Product option po LEFT JOIN ` . DB PREFIX . Option` o ON (po.Option id = o.Option id) LEFT JOIN . DB PREFIX .

Option description od ON (o.Option id = od.Option id) WHERE po.Product id = ‘ . (int)$product id . ‘ AND od.Language id = ‘ . (int)$this->config->get(‘config language id’) . ‘ ORDER BY o.Sort order);

bitcoin value in dollars

Foreach ($product option query->rows as $product option) {

If ($product option[‘type’] == ‘select’ || $product option[‘type’] == ‘radio’ || $product option[‘type’] == ‘checkbox’ || $product option[‘type’] == ‘image’) {

$product option value data = array();

$product option value query = $this->db->query(SELECT * FROM . DB PREFIX . Product option value pov LEFT JOIN . DB PREFIX . Option value ov ON (pov.Option value id = ov.Option value id) LEFT JOIN . DB PREFIX . Option value description ovd ON (ov.Option value id = ovd.Option value id) WHERE pov.Product id = ‘ . (int)$product id . ‘ AND pov.Product option id = ‘ . (int)$product option[‘product option id’] . ‘ AND ovd.Language id = ‘ . (int)$this->config->get(‘config language id’) . ‘ ORDER BY ov.Sort order);

Foreach ($product option value query->rows as $product option value) {

bitcoin value in dollars

$product option value data[] = array(

‘product option value id’ => $product option value[‘product option value id’],

‘option value id’ => $product option value[‘option value id’],

‘name’ => $product option value[‘name’],

‘image’ => $product option value[‘image’],

‘quantity’ => $product option value[‘quantity’],

‘subtract’ => $product option value[‘subtract’],

‘price’ => $product option value[‘price’],

‘price prefix’ => $product option value[‘price prefix’],

‘weight’ => $product option value[‘weight’],

‘weight prefix’ => $product option value[‘weight prefix’]

);

}

$product option data[] = array(

‘product option id’ => $product option[‘product option id’],

‘option id’ => $product option[‘option id’],

‘name’ => $product option[‘name’],

‘type’ => $product option[‘type’],

bitcoin value in dollars

‘option value’ => $product option value data,

‘required’ => $product option[‘required’]

);

} else {

$product option data[] = array(

‘product option id’ => $product option[‘product option id’],

‘option id’ => $product option[‘option id’],

‘name’ => $product option[‘name’],

‘type’ => $product option[‘type’],

‘option value’ => $product option[‘option value’],

‘required’ => $product option[‘required’]

);

}

}

Return $product option data;

}

Controller $this->data[‘options’] = array();

Foreach ($this->model catalog product->getproductoptions($this- >request->get[‘product id’]) as $option) {

If ($option[‘type’] == ‘select’ || $option[‘type’] == ‘radio’ || $option[‘type’] == ‘checkbox’ || $option[‘type’] == ‘image’) {

$option value data = array();

Foreach ($option[‘option value’] as $option value) {

bitcoin value in dollars

If (!$option value[‘subtract’] || ($option value[‘quantity’] > 0)) {

If ((($this->config->get(‘config customer price’) && $this->customer->islogged()) || !$this->config->get(‘config customer price’)) && (float)$option value[‘price’]) {

$price = $this->currency->format($this->tax->calculate($option value[‘price’], $product info[‘tax class id’], $this->config->get(‘config tax’)));

} else {

$price = false;

}

$option value data[] = array(

‘product option value id’ => $option value[‘product option value id’],

‘option value id’ => $option value[‘option value id’],

‘name’ => $option value[‘name’],

‘image’ => $this->model tool image->resize($option value[‘image’], 50, 50),

‘price’ => $price,

‘price prefix’ => $option value[‘price prefix’]

bitcoin value in dollars

);

}

}

$this->data[‘options’][] = array(

‘product option id’ => $option[‘product option id’],

‘option id’ => $option[‘option id’],

‘name’ => $option[‘name’],

‘type’ => $option[‘type’],

‘option value’ => $option value data,

‘required’ => $option[‘required’]

);

} elseif ($option[‘type’] == ‘text’ || $option[‘type’] == ‘textarea’ || $option[‘type’] == ‘file’ || $option[‘type’] == ‘date’ || $option[‘type’] == ‘datetime’ || $option[‘type’] == ‘time’) {

$this->data[‘options’][] = array(

‘product option id’ => $option[‘product option id’],

‘option id’ => $option[‘option id’],

‘name’ => $option[‘name’],

‘type’ => $option[‘type’],

‘option value’ => $option[‘option value’],

‘required’ => $option[‘required’]

);

}

}

The problem here is the settings… Product should not have a price $0.0 while options are setting the product’s price.Bitcoin value in dollars instead of this the product should have some price (you can use the lowest possible for the product) and options then only modify this base price:

• T-shirt polo: $10.0

• small (S): +$0.0

• medium (M): +$1.0

• large (L): +$2.0

• X-large (XL): +$3.0

• XX-large (XXL): +$4.0

If your store is selling products where options will always modify the price, you can then only check (in the template) whether the product has options, and in this case you can display something like price: starting from $10.0, if the products has no options, display it like usual, e.G. Price: $10.0.

Or is there any big reason for setting the base price to 0.0?

Just my very own opinion: people don’t like (in general) when a T-shirt (or any other piece of clothes) has different price regarding the size they need and moreover they can be discouraged when their size is more expensive.Bitcoin value in dollars it is a good practice to calculate some average price for a T-shirt (or any other piece of clothes) and use this average price for all sizes. If I had to do that, I would expect to sell e.G. 20% of S, 30% of M and L, 15% of XL and 5% of XXL – then I could calculate the average price as 0.2 x 10 + 0.3 x 11 + 0.3 x 12 + 0.15 x 13 + 0.05 x 14 = 2 + 3.3 + 3.6 + 1.95 + 0.7 = 11.55. I will then use this average price for all sizes of this very shirt…

Maybe replace order in mysql query (model file) $product option value query = $this->db->query(SELECT * FROM . DB PREFIX . Product option value pov LEFT JOIN . DB PREFIX . Option value ov ON (pov.Option value id = ov.Option value id) LEFT JOIN . DB PREFIX . Option value description ovd ON (ov.Option value id = ovd.Option value id) WHERE pov.Product id = ‘ . (int)$product id . ‘ AND pov.Product option id = ‘ . (int)$product option[‘product option id’] . ‘ AND ovd.Language id = ‘ . (int)$this->config->get(‘config language id’) . ‘ ORDER BY ov.Sort order);

bitcoin value in dollars

To $product option value query = $this->db->query(SELECT * FROM . DB PREFIX . Product option value pov LEFT JOIN . DB PREFIX . Option value ov ON (pov.Option value id = ov.Option value id) LEFT JOIN . DB PREFIX . Option value description ovd ON (ov.Option value id = ovd.Option value id) WHERE pov.Product id = ‘ . (int)$product id . ‘ AND pov.Product option id = ‘ . (int)$product option[‘product option id’] . ‘ AND ovd.Language id = ‘ . (int)$this->config->get(‘config language id’) . ‘ ORDER BY pov.Price ASC);

Ov.Sort order >>

Pov.Price ASC

Or

Ov.Sort order >>

Pov.Price DESC

Stack exchange

Network

• technology

• life / arts

• culture / recreation

• science

• other

• stack overflow

• server fault

• super user

• web applications

• ask ubuntu

• webmasters

• game development

• tex – latex

bitcoin value in dollars

• software engineering

• unix & linux

• ask different (apple)

• wordpress development

• geographic information systems

• electrical engineering

• android enthusiasts

• information security

• database administrators

• drupal answers

• sharepoint

• user experience

• mathematica

• salesforce

• expressionengine® answers

• stack overflow em português

• blender

• network engineering

• cryptography

• code review

• magento

• software recommendations

• signal processing

• emacs

• raspberry pi

• stack overflow на русском

• programming puzzles & code golf

• stack overflow en español

• ethereum

• data science

• arduino

• bitcoin

More (28)

• photography

• science fiction & fantasy

• graphic design

• movies & TV

• music: practice & theory

• worldbuilding

• seasoned advice (cooking)

• home improvement

• personal finance & money

bitcoin value in dollars

• academia

• law

More (16)

• english language & usage

• skeptics

• mi yodeya (judaism)

• travel

• christianity

• english language learners

• japanese language

• arqade (gaming)

• bicycles

• role-playing games

• anime & manga

• puzzling

• motor vehicle maintenance & repair

More (32)

• mathoverflow

• mathematics

• cross validated (stats)

• theoretical computer science

• physics

• chemistry

• biology

• computer science

• philosophy

More (10)

• meta stack exchange

• stack apps

• API

• data

• area 51