Not getting any POST value from custom front controller Prestashop 1.6.1.8

54 views Asked by At

I'm looking to get some data with a POST request onto a custom front controller in Prestashop 1.6.1.8. But when I do var_dump($_POST), it shows array(0) { }.

I tried using another Prestashop's installation (same version) but on a Docker container, and it works really well. Just not when on the live website.

Here is the full code of the function:

public function postProcess(){
        $obj_advansedcoupons = new advansedcoupons();
        $data_translate = $obj_advansedcoupons->translateCustom();
        $type = Tools::getValue('type');
        $amount = Tools::getValue('amount');
        $email = Tools::getValue('accemail');
        var_dump($_GET);
        var_dump($_POST);
        print_r($type);
        print_r($amount);
        print_r($email);
        $b_type_voucher = Tools::strtoupper($type);
        
        $validity = $data_translate['voucher_duration'].date('Y-m-d', time() + 30*24*60*60);

        $sql_customer_by_email = 'SELECT id_customer FROM '._DB_PREFIX_.'customer WHERE email = "'.$email.'";';
        $id_customer = Db::getInstance()->getValue($sql_customer_by_email);
        if($id_customer){
            if($type && $amount && $email && $validity){
                $cartRule = new CartRule(
                    null,
                    Configuration::get('PS_LANG_DEFAULT'),
                    Configuration::get('PS_SHOP_DEFAULT')
                );
                $cartRule->name = .$email;
                $cartRule->reduction_percent = (float)$amount;
                $cartRule->date_to = date('Y-m-d H:i:s', time() + (int)30*24*60*60);
                $cartRule->quantity = 1;
                $cartRule->quantity_per_user = 1;
                $cartRule->date_from = date('Y-m-d H:i:s', time());
                $cartRule->code = Configuration::get('COUPON_PREF_'.$b_type_voucher).Tools::passwdGen(6);
                $cartRule->id_customer = (int)$id_customer;
                $cartRule->shop_restriction = (Shop::isFeatureActive())? 1: 0;
                $cartRule->add();
    
                $sql = 'INSERT INTO '._DB_PREFIX_.'ws_coupons (email, type, code, amount, validity) VALUES ("'.$email.'", "'.$type.'", "'.$cartRule->code.'", "'.$amount.'", "'.$cartRule->date_to.'")';   
                Db::getInstance()->execute($sql);
            }
        }
    }

Has anyone encountered this issue before ?

0

There are 0 answers