Exemple #1
0
 public static function getCurrencyPriceProduct(Product $product, Order $order = null, SpecialPriceList $specialPrice, $price)
 {
     $currency = Currency::getMainCurrency();
     if ($product->currency_id !== $currency->id) {
         $foreignCurrency = Currency::findById($product->currency_id);
         $price = $price / $foreignCurrency->convert_nominal * $foreignCurrency->convert_rate;
     }
     return round($price, 2);
 }
Exemple #2
0
 /**
  * Formats price in product's currency
  * @param bool $oldPrice
  * @param bool $schemaOrg
  * @return string
  */
 public function nativeCurrencyPrice($oldPrice = false, $schemaOrg = true)
 {
     $currency = Currency::findById($this->currency_id);
     return $this->formattedPrice($currency, $oldPrice, $schemaOrg);
 }
            $index++;
            ?>
                    <div class="panel panel-default" data-addon="<?php 
            echo $addon->id;
            ?>
">
                        <div class="panel-body">
                            <div class="btn btn-xs btn-info pull-left handle" style="margin-right: 20px;cursor: move;">

                                <i class="fa fa-arrows"></i>

                            </div>
                            <div class="pull-right btn-group">
                                <div class="btn btn-xs btn-default">
                                    <?php 
            $currency = \app\modules\shop\models\Currency::findById($addon->currency_id);
            echo $currency->format($addon->price);
            ?>

                                </div>
                                <?php 
            echo Html::a(\kartik\icons\Icon::show('trash-o') . ' ' . Yii::t('app', 'Delete'), '#', ['data-id' => $addon->id, 'class' => 'btn btn-xs btn-danger remove-addon']);
            ?>
                            </div>
                            <?php 
            echo Html::encode($addon->name);
            ?>
                        </div>
                    </div>
                <?php 
        }
 public function actionAjaxSearchAddons()
 {
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $result = ['more' => false, 'results' => []];
     $search = Yii::$app->request->get('search');
     if (!empty($search['term'])) {
         $query = new \yii\db\Query();
         $query->select('id, name as text, price, currency_id')->from(Addon::tableName())->andWhere(['like', 'name', $search['term']])->orderBy(['name' => SORT_ASC]);
         $command = $query->createCommand();
         $data = $command->queryAll();
         $data = array_map(function ($item) {
             $currency = Currency::findById($item['currency_id']);
             $price = $currency->format($item['price']);
             $item['text'] .= ' - ' . $price;
             return $item;
         }, $data);
         $result['results'] = array_values($data);
     }
     return $result;
 }