add customer cart
This commit is contained in:
24
common/components/CurrencyAwareBehavior.php
Normal file
24
common/components/CurrencyAwareBehavior.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace common\components;
|
||||
|
||||
use yii\base\Behavior;
|
||||
use common\models\Currency;
|
||||
|
||||
class CurrencyAwareBehavior extends Behavior{
|
||||
|
||||
|
||||
public function getCurrencyName(){
|
||||
$result = "";
|
||||
$currency = $this->owner->currency;
|
||||
if (isset($currency)){
|
||||
$result = $currency->name;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getCurrency(){
|
||||
return $this->owner->hasOne( Currency::className(), ["id_currency" =>"id_currency" ] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
25
common/components/DiscountAwareBehavior.php
Normal file
25
common/components/DiscountAwareBehavior.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace common\components;
|
||||
|
||||
use yii\base\Behavior;
|
||||
use common\models\Account;
|
||||
use common\models\Discount;
|
||||
|
||||
class DiscountAwareBehavior extends Behavior{
|
||||
|
||||
|
||||
public function getDiscountName(){
|
||||
$result = "";
|
||||
$discount = $this->owner->discount;
|
||||
if (isset($discount)){
|
||||
$result = $discount->name;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getDiscount(){
|
||||
return $this->owner->hasOne( Discount::className(), ["id_discount" =>"id_discount" ] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
25
common/components/ProductAwareBehavior.php
Normal file
25
common/components/ProductAwareBehavior.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace common\components;
|
||||
|
||||
use yii\base\Behavior;
|
||||
use common\models\Account;
|
||||
use common\models\Product;
|
||||
|
||||
class ProductAwareBehavior extends Behavior{
|
||||
|
||||
/** @var $product common\models\Product*/
|
||||
public function getProductName(){
|
||||
$result = "";
|
||||
$product = $this->owner->product;
|
||||
if (isset($product)){
|
||||
$result = $product->name;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getProduct(){
|
||||
return $this->owner->hasOne( Product::className(), ["id_product" =>"id_product" ] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
24
common/components/SaleAwareBehavior.php
Normal file
24
common/components/SaleAwareBehavior.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace common\components;
|
||||
|
||||
use yii\base\Behavior;
|
||||
use common\models\Sale;
|
||||
|
||||
class SaleAwareBehavior extends Behavior{
|
||||
|
||||
|
||||
public function getSaleName(){
|
||||
$result = "";
|
||||
$sale = $this->owner->sale;
|
||||
if (isset($sale)){
|
||||
$result = $sale->name;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getSale(){
|
||||
return $this->owner->hasOne( Sale::className(), ["id_sale" =>"id_sale" ] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user