common/components/CartFunctionality.php
/*
     * check this code is applicable for this user/product
     */
check this code is applicable for this user/product
check this code is applicable for this user / product
public static function PromotionProduct($code_exists, $code) {
        $products = explode(',', $code_exists->product_id);
        $users = explode(',', $code_exists->user_id);
        $oreder_setails = Cart::find()->where(['user_id' => Yii::$app->user->identity->id])->all();
        $exist = 0;
        if ($code_exists->promotion_type == 1 || $code_exists->promotion_type == 3) {
            foreach ($oreder_setails as $value) {
                if (in_array($value->product_id, $products)) {
                    $exist = 1;
                }
            }
        }
        if ($code_exists->promotion_type == 2 || $code_exists->promotion_type == 3) {
            if (in_array(Yii::$app->user->identity->id, $users))
                $exist = 1;
        }
        return $exist;
    }
public static function PromotionProduct ( $ code_exists , $ code ) { $ products = explode ( ',' , $ code_exists -> product_id ) ; $ users = explode ( ',' , $ code_exists -> user_id ) ; $ oreder_setails = Cart :: find ( ) -> where ( [ 'user_id' => Yii :: $ app -> user -> identity -> id ] ) -> all ( ) ; $ exist = 0 ; if ( $ code_exists -> promotion_type == 1 || $ code_exists -> promotion_type == 3 ) { foreach ( $ oreder_setails as $ value ) { if ( in_array ( $ value -> product_id , $ products ) ) { $ exist = 1 ; } } } if ( $ code_exists -> promotion_type == 2 || $ code_exists -> promotion_type == 3 ) { if ( in_array ( Yii :: $ app -> user -> identity -> id , $ users ) ) $ exist = 1 ; } return $ exist ; }
check this code is applicable for this user/product
check this code is applicable for this user / product