-1

i have colour options in opencart 3. black main +0 $10, option1 red +$2 ($12), option2 yellow +$3 ($13). sending prices to xml. i do not want black price in results.

$options = $this->model_catalog_product->getProductOptions($product['product_id']);
                foreach ($options as $option) {
                foreach ($option['product_option_value'] as $value) {
                $output .= '<outab>';
                $output .= '<Optional="' . $option['name'] . '" >' . $value['name'] . '</Optional>';
                $output .= '<Stock>' . $value['quantity']. '</stock>';
                $output .= '<Stocktab></Stoktab>';
                $output .= '<Stockmoney>' . ($value['price'] + $product['price']) * 1.10 . '</Stockmoney>';

selects the options, writes the prices in stockmoney tag, it writes blacks price.i want no result in black price.

$output .= '<Stockmoney>' . ($value['price'] + $product['price']) * 1.10 . '</Stockmoney>';

i tried (blacks price is main price, it has not $value['price'] so counts 0)

$blackprice = $value['price'] + $product['price'];
if ($blackprice = $product['price']) 
    { $blackprice ;} 
    else {empty($blackprice);}

$output .= '<Stockmoney>' . ($blackprice) * 1.10 . '</Stockmoney>';
  • you have messed up `=` vs `==` but im not sure that's the root issue here –  Apr 22 '19 at 21:48
  • tried == but red warning – user10654264 Apr 22 '19 at 21:54
  • What are you trying to achieve with `{ $blackprice ;} else {empty($blackprice);}`. Normally you would have an assignment but your not doing anything with these lines of code. – Nigel Ren Apr 23 '19 at 06:59
  • You should also NOT build XML as strings as this can cause errors (for example ``). You can use SImpleXML to generate the data and then get it to create the XML string. – Nigel Ren Apr 23 '19 at 07:01

1 Answers1

0

more simple

$a= $value['price'] + $product['price']; if ($a > $product['price']) { $a;} else { $a = null; }

null outputs 0 which i do not want.

$value['price'] can be 0, if it is 0 than the result must be shown below. only xml tags without anything. <Stockmoney></Stockmoney>