frontend/controllers/AjaxController.php
/**
     * Save product to wish list.
     * @param product id
     * if user logged in set user id otherwise redirect to login
     */
Save product to wish list.
@param product id
if user logged in set user id otherwise redirect to login
Save product to wish list . @param product id if user logged in set user id otherwise redirect to login
public function actionSavewishlist() {
        if (Yii::$app->request->isAjax) {
            $canonical = $_POST['product'];
            $product = \common\models\Product::find()->where(['canonical_name' => $canonical, 'status' => '1'])->one();
            $product_id = $product->id;
            if ($product_id != '') {
                $flag = Yii::$app->CartFunctionality->AddToWishlist($product_id);
            }
            echo $flag;
        }
    }
public function actionSavewishlist ( ) { if ( Yii :: $ app -> request -> isAjax ) { $ canonical = $ _POST [ 'product' ] ; $ product = \ common \ models \ Product :: find ( ) -> where ( [ 'canonical_name' => $ canonical , 'status' => '1' ] ) -> one ( ) ; $ product_id = $ product -> id ; if ( $ product_id != '' ) { $ flag = Yii :: $ app -> CartFunctionality -> AddToWishlist ( $ product_id ) ; } echo $ flag ; } }
Save product to wish list.
Save product to wish list .