Пример #1
0
 public function getAllProductsByCategory($category_id)
 {
     $this->andWhere('status =:status', [':status' => 1]);
     $this->with('productCategories');
     $this->limit(Custom::getCustomConfig()['max_top_rated']);
     $this->orderBy('id DESC');
     return $this;
 }
Пример #2
0
 public function actionCheckout()
 {
     $user_id = 0;
     if (Yii::$app->user->isGuest) {
         return $this->redirect('/login');
     }
     if (!Yii::$app->user->isGuest) {
         $user_id = Yii::$app->user->identity->id;
     }
     $cart_json = [];
     if (isset($_COOKIE["cart_{$user_id}"])) {
         $cart_json = Json::decode($_COOKIE["cart_{$user_id}"]);
     } elseif (isset($_COOKIE["cart_0"])) {
         $cart_json = Json::decode($_COOKIE["cart_0"]);
     } else {
         return $this->redirect('/shop');
         Yii::$app->end();
     }
     $ar_product_id = array_keys($cart_json);
     $cart_items = Product::find()->where(['in', 'id', $cart_json])->all();
     if (isset($_POST) && !empty($_POST['place_order'])) {
         $grand_total = 0.0;
         $grand_total_purchase_price = 0.0;
         foreach ($cart_items as $ci) {
             $unit_price = floatval($ci->selling_price);
             $qty = intval($cart_json[$ci->id]['qty']);
             $row_total = $unit_price * $qty;
             $grand_total += $row_total;
             $unit_purchase_price = floatval($ci->purchase_price);
             $row_total_purchase_price = $unit_purchase_price * $qty;
             $grand_total_purchase_price += $row_total_purchase_price;
         }
         $order = new Order();
         $order->bill_number = Custom::getUniqueId(0, 6);
         $order->member_id = $user_id;
         $order->total_amount = $grand_total;
         $order->total_payable = $grand_total;
         $order->payment_method = $_POST['payment_method'];
         $order->beforeSave(true);
         if ($order->validate() && $order->insert()) {
             $product = '';
             foreach ($cart_items as $ci) {
                 $unit_price = floatval($ci->selling_price);
                 $qty = intval($cart_json[$ci->id]['qty']);
                 $row_total = $unit_price * $qty;
                 $product .= "{$ci->id},";
                 $cart = new Cart();
                 $cart->order_id = $order->id;
                 $cart->product_id = $ci->id;
                 $cart->unit_selling_price = $ci->selling_price;
                 $cart->quantity_sold = $qty;
                 $cart->subtotal_payable = $row_total;
                 $cart->subtotal_paid = $row_total;
                 $cart->beforeSave(true);
                 $cart->insert();
             }
         }
         $sale_amount = $grand_total - $grand_total_purchase_price;
         $app_root = \Yii::getAlias('@approot');
         include "{$app_root}/affiliate/controller/record-sale.php";
         $cookies = Yii::$app->response->cookies;
         if (isset($_COOKIE['cart_' . $user_id])) {
             $cookies->remove('cart_' . $user_id);
             unset($cookies['cart_' . $user_id]);
         }
         if (isset($_COOKIE['cart_0'])) {
             $cookies->remove('cart_0');
             unset($cookies['cart_0']);
         }
         return $this->redirect(['/member/order', 'id' => $order->id]);
     }
     return $this->render('checkout', ['cart_items' => $cart_items, 'cookie_data' => $cart_json]);
 }
Пример #3
0
<?php

use yii\helpers\Html;
use common\helpers\Custom;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Manufacturers';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="manufacturer-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Create Manufacturer', ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', 'address:ntext', 'contact_number', 'created_date', ['attribute' => 'status', 'value' => function ($model) {
    return Custom::getStatusArray()[$model->status];
}], ['class' => 'yii\\grid\\ActionColumn']], 'showFooter' => true, 'layout' => '{summary}{items}{pager}', 'filterPosition' => 'footer']);
?>

</div>
Пример #4
0
                                                </span>
                                            </td>
                                        </tr>

                                        <tr class="shipping">
                                            <th>Shipping and Handling</th>
                                            <td>Free Shipping</td>
                                        </tr>

                                        <tr class="order-total">
                                            <th>Order Total</th>
                                            <td>
                                                <strong>
                                                    <span class="amount">
                                                        <?php 
    echo Custom::getCurrencySymbol()['bdt'] . ' ' . number_format($grand_total, 2);
    ?>
                                                    </span>
                                                </strong>
                                            </td>
                                        </tr>
                                        
                                    </tfoot>
                                </table>

                                <?php 
    echo Html::beginForm('/checkout', 'post', ['name' => 'place_order']);
    ?>
                                <div id="payment">
                                    <ul class="payment_methods methods">
                                        <li class="payment_method_bacs">
Пример #5
0
?>

    <?php 
echo $form->field($model, 'display_name')->textInput(['maxlength' => true]);
?>

    <?php 
$data_parent_categories = ArrayHelper::map(Category::find()->parentCategoryForDropdown()->asArray()->all(), 'id', 'display_name');
echo $form->field($model, 'parent_catrgory_id')->dropDownList($data_parent_categories, ['prompt' => 'Select']);
?>

    <?php 
if (!empty($model->id)) {
    ?>
        <?php 
    echo $form->field($model, 'status')->dropDownList(Custom::getStatusArray());
    ?>
    <?php 
}
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Пример #6
0
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Cancel'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to cancel this order?'), 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['bill_number', ['attribute' => 'member_id', 'value' => $model->member->memberProfiles[0]->name], 'total_amount', 'total_payable', ['attribute' => 'has_due', 'value' => Custom::getYesNoArray()[$model->has_due]], 'created_date', 'updated_date', ['attribute' => 'status', 'value' => Custom::getOrderStatusArray()[$model->status]]]]);
?>

</div>

<div class="clearfix"></div>

<div class="product-order-cart panel panel-default">

    <div class="panel-heading"><h3>Ordered Items</h3></div>

    <div class="panel-body">

        <?php 
if (!empty($model->carts)) {
    ?>
Пример #7
0
use yii\helpers\Html;
use common\helpers\Custom;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Manufacturer */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Manufacturers', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="manufacturer-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'name', 'address:ntext', 'contact_number', 'created_date', 'updated_date', ['attribute' => 'status', 'value' => Custom::getStatusArray()[$model->status]]]]);
?>

</div>
Пример #8
0
    echo Html::a('<i class="fa fa-shopping-cart"></i> Add to cart', Url::to(['/cart', 'id' => $tp->id, 'name' => Html::encode($tp->name)]), ['class' => 'add-to-cart-link', 'data-id' => $tp->id]);
    ?>
                                        <?php 
    echo Html::a('<i class="fa fa-link"></i> See details', Url::to(['/item', 'id' => $tp->id, 'name' => Html::encode($tp->name)]), ['class' => 'view-details-link']);
    ?>
                                    </div>
                                </div>

                                <h2><?php 
    echo Html::a($tp->display_name, Url::to(['/item', 'id' => $tp->id, 'name' => Html::encode($tp->name)]));
    ?>
</h2>

                                <div class="product-carousel-price">
                                    <ins><?php 
    echo Custom::getCurrencySymbol()['bdt'] . " {$tp->selling_price}";
    ?>
</ins>
                                </div> 
                            </div>

                        <?php 
}
?>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div> <!-- End main content area -->
Пример #9
0
?>
<div class="category-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
    </p>

    <?php 
$parent_category_name = NULL;
if (!empty($model->parent_catrgory_id)) {
    $parent_category = Category::find()->parentCategoryById($model->parent_catrgory_id)->one();
    $parent_category_name = $parent_category->display_name;
}
?>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'name', 'display_name', ['attribute' => 'parent_catrgory_id', 'value' => $parent_category_name], 'created_date', 'updated_date', ['attribute' => 'status', 'value' => Custom::getStatusArray()[$model->status]]]]);
?>

</div>
Пример #10
0
    <div class="single-product single-shop-product">
        <div class="product-upper">
            <?php 
$img_src = "/uploads/product_image/{$model->resourcesProducts[0]->resources->value}";
echo Html::img($img_src, ['alt' => $model->display_name]);
?>
        </div>
        <h2>
            <?php 
echo Html::a($model->display_name, ['/item', 'id' => $model->id, 'name' => Html::encode($model->name)]);
?>
        </h2>
        <div class="product-carousel-price">
            <ins>
                <?php 
echo Custom::getCurrencySymbol()['bdt'] . ' ' . $model->selling_price;
?>
            </ins>
        </div>  

        <div class="product-option-shop">
            <?php 
echo Html::a('<i class="fa fa-shopping-cart"></i> Add to cart', Url::to(['/cart', 'id' => $model->id, 'name' => Html::encode($model->name)]), ['class' => 'add-to-cart-link add_to_cart_button_1', 'data-id' => $model->id]);
?>
            <?php 
// echo Html::a('Add to cart', Url::to(['/cart', 'id' => $model->id, 'name' => Html::encode($model->name)]), ['class' => '', 'data-id' => $model->id]);
?>
        </div>                       
    </div>
</li>
Пример #11
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="container">
    <div class="profile-view">

        <h1><?php 
echo Html::encode($this->title);
?>
</h1>

        <p>
            <?php 
echo Html::a(Yii::t('app', 'Orders'), ['orders'], ['class' => 'btn btn-info', 'data' => ['method' => 'post']]);
echo Html::a(Yii::t('app', 'Set Cart Amount'), ['cart_amount'], ['class' => 'btn btn-warning', 'data' => ['method' => 'post']]);
?>
        </p>

        <?php 
//    $parent_category_name = NULL;
//    if (!empty($model->parent_catrgory_id)) {
//        $parent_category = Category::find()->parentCategoryById($model->parent_catrgory_id)->one();
//        $parent_category_name = $parent_category->display_name;
//    }
?>

        <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['email', ['attribute' => 'name', 'value' => $model->memberProfiles[0]->name], ['attribute' => 'address', 'value' => $model->memberProfiles[0]->address], ['attribute' => 'contact_number', 'value' => $model->memberProfiles[0]->contact_number], ['attribute' => 'max_cart_amount', 'value' => Custom::getCurrencySymbol()['bdt'] . ' ' . number_format($model->memberProfiles[0]->max_cart_amount, 2)]]]);
?>
    </div>
</div>