Jump to content

How can i pass data to Controller?


arkanimus

Recommended Posts

Hi i want to senddata way Post from the View To the Controller, but i not have idea how to do that.

 

i have the follow code in the shopping-cart.tpl File:

 

<form action="{if $opc}{$link->getPageLink('order-opc', true)}{else}{$link->getPageLink('order', true)}{/if}" method="post" id="formcajas">
<fieldset>
 
                            
<h4><label for="lblCajas">{l s='Cajas'}</label></h4>
<p>
<input type="text" class="cajas" id="txtCajas" name="txtCajas"/>
</p>
        
<p class="submit"><input type="hidden" name="ingresaCajas" /><input type="submit" name="ingresaCajas" value="{l s='OK'}" class="button" /></p>
 
 
</fieldset>
</form>
 
The Controller is OrderController, but the method $_POST does not works..
what can i do?? help please! thanks you!
Edited by arkanimus (see edit history)
Link to comment
Share on other sites

please enabled the debug mode ..

and track the what type is error ?

 

you enabled debug mode is :define('_PS_MODE_DEV_', false) inssed of define('_PS_MODE_DEV_', true);

 

config/defines.inc.php file

define('_PS_MODE_DEV_', true);
if (_PS_MODE_DEV_)
{
    @ini_set('display_errors', 'on');    
    define('_PS_DEBUG_SQL_', true);
    /* Compatibility warning */
    define('_PS_DISPLAY_COMPATIBILITY_WARNING_', true);
}

Edited by Nishith (see edit history)
Link to comment
Share on other sites

 

please enabled the debug mode ..

and track the what type is error ?

 

you enabled debug mode is :define('_PS_MODE_DEV_', false) inssed of define('_PS_MODE_DEV_', true);

 

config/defines.inc.php file

define('_PS_MODE_DEV_', true);
if (_PS_MODE_DEV_)
{
    @ini_set('display_errors', 'on');    
    define('_PS_DEBUG_SQL_', true);
    /* Compatibility warning */
    define('_PS_DISPLAY_COMPATIBILITY_WARNING_', true);
}

kmr6.png

 

Notice: Undefined index: cantidad in /var/www/mayorista10/cache/smarty/compile/2f5c149962cab8fc9bc0c9e32fc32772758fbf56.file.shopping-cart.tpl.php on line 371 Notice: Trying to get property of non-object in /var/www/mayorista10/cache/smarty/compile/2f5c149962cab8fc9bc0c9e32fc32772758fbf56.file.shopping-cart.tpl.php on line 371 $ 854

 

 

In the Shopping-car.tpl i have this code:

 

<form action="{if $opc}{$link->getPageLink('order-opc', true)}{else}{$link->getPageLink('order', true)}{/if}" method="post" id="formcajas">

<fieldset>
 
                            
<h4><label for="lblCajas">{l s='Cajas'}</label></h4>
<p>
<input type="text" class="cajas" id="txtCajas" name="txtCajas"/>
</p>
        
<p class="submit"><input type="hidden" name="ingresaCajas" /><input type="submit" name="ingresaCajas" value="{l s='OK'}" class="button" /></p>
 
 
</fieldset>
</form>
 
    
{/if}
</td>
{if $use_taxes}
<td colspan="2" class="price total_price_container" id="total_price_container">
<p>{l s='Total:'}</p>
<span id="total_price">{displayPrice price=($total_price-$cantidad)}</span>
</td>
{else}
<td colspan="2" class="price total_price_container" id="total_price_container">
<p>{l s='Total:'}</p>
<span id="total_price">{displayPrice price=$total_price_without_tax}</span>
</td>
{/if}
</tr>
 
in the Controller i have this:
 
public function init()
{
global $orderTotal;
 
parent::init();
 
$this->step = (int)(Tools::getValue('step'));
if (!$this->nbProducts)
$this->step = -1;
$cantidad = Tools::getValue('txtCajas');
// If some products have disappear
if (!$this->context->cart->checkQuantities())
{
$this->step = 0;
$this->errors[] = Tools::displayError('An item in your cart is no longer available in this quantity, you cannot proceed with your order.');
}
 
// Check minimal amount
.
.
.thanks you for reply!
 
Edited by arkanimus (see edit history)
Link to comment
Share on other sites

hello

try this your order controller


public function init()
    {
        global $orderTotal;

        parent::init();
        
        if(Tools::issubmit('ingresaCajas'))
        {
            $cantidad = Tools::getValue('txtCajas');
            echo $cantidad;
            
        }
.....................
.....................

Edited by Nishith (see edit history)
Link to comment
Share on other sites

 

hello

try this your order controller


public function init()
    {
        global $orderTotal;

        parent::init();
        
        if(Tools::issubmit('ingresaCajas'))
        {
            $cantidad = Tools::getValue('txtCajas');
            echo $cantidad;
            
        }
.....................
.....................

Nothing Happened :'(

 

kmr6.png

Notice: Undefined index: cantidad in /var/www/mayorista10/cache/smarty/compile/2f5c149962cab8fc9bc0c9e32fc32772758fbf56.file.shopping-cart.tpl.php on line 371 Notice: Trying to get property of non-object in /var/www/mayorista10/cache/smarty/compile/2f5c149962cab8fc9bc0c9e32fc32772758fbf56.file.shopping-cart.tpl.php on line 371 $ 854

 

n07s.png

 

04o6.png

Edited by arkanimus (see edit history)
Link to comment
Share on other sites

Thank you it Work's!!!!: 

 

Notice: Constant _PS_DEBUG_SQL_ already defined in /var/www/mayorista10/config/defines.inc.php on line 33 Notice: Constant _PS_DISPLAY_COMPATIBILITY_WARNING_ already defined in /var/www/mayorista10/config/defines.inc.php on line 35 try1 cantidad10

 

echo show : try1 cantidad10

 

but the view did not take the value 

 

<span id="total_price">{displayPrice price=($total_price-$cantidad)}</span>

 

Notice: Undefined index: cantidad in /var/www/mayorista10/cache/smarty/compile/2f5c149962cab8fc9bc0c9e32fc32772758fbf56.file.shopping-cart.tpl.php on line 356 Notice: Trying to get property of non-object in /var/www/mayorista10/cache/smarty/compile/2f5c149962cab8fc9bc0c9e32fc32772758fbf56.file.shopping-cart.tpl.php on line 356 $ 854

 

And now how can i send the var $cantidad from controller to the view???!!

 

Thanks u!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...