Jump to content

Problema invocar una funcion, Ayuda!


Recommended Posts

Hola Amigos, tengo un problema al momento de invocar una función en prestashop:

 

tengo lo siguiente:

 

Validate2

 

<?php
 
 
/**
 * @since 1.5.0
 */
class visanetValidation2ModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public $display_column_left = false;
 
public function postProcess()
{
if ($this->context->cart->id_customer == 0 || $this->context->cart->id_address_delivery == 0 || $this->context->cart->id_address_invoice == 0 || !$this->module->active)
Tools::redirectLink(__PS_BASE_URI__.'order.php?step=1');
 
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module)
if ($module['name'] == 'visanet')
{
$authorized = true;
break;
}
if (!$authorized)
die(Tools::displayError('This payment method is not available.'));
 
$customer = new Customer($this->context->cart->id_customer);
if (!Validate::isLoadedObject($customer))
Tools::redirectLink(__PS_BASE_URI__.'order.php?step=1');
 
if (Tools::getValue('confirm'))
{
$customer = new Customer((int)$this->context->cart->id_customer);
$total = $this->context->cart->getOrderTotal(true, Cart::BOTH);
$this->module->validateOrder((int)$this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key);
Tools::redirectLink(__PS_BASE_URI__.'order-confirmation.php?key='.$customer->secure_key.'&id_cart='.(int)$this->context->cart->id.'&id_module='.(int)$this->module->id.'&id_order='.(int)$this->module->currentOrder);
}
}
 
public static function getCategoryParent(){
      return 'Hola desde Product.php';
 
}
/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
 
$this->context->smarty->assign(array(
'total' => $this->context->cart->getOrderTotal(true, Cart::BOTH),
'this_path' => $this->module->getPathUri(),//keep for retro compat
'this_path_cod' => $this->module->getPathUri(),
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/'
));
 
$this->setTemplate('validation2.tpl');
}
}
 
 
y en mi tpl
 
 
 
 
{capture name=path}{l s='Shipping' mod='visanet'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}
 
<h2>{l s='Order summation' mod='visanet'}</h2>
 
{assign var='current_step' value='payment'}
{include file="$tpl_dir./order-steps.tpl"}
 
 
 
 
 
{$a|getCategoryParent()}
 
<form action="{$link->getModuleLink('visanet', 'validation', [], true)|escape:'html'}" method="post">
<input type="hidden" name="confirm" value="1" />
<p>
<img src="{$this_path_cod}visanet.jpg" alt="{l s='Cash on delivery (COD) payment' mod='visanet'}" style="float:left; margin: 0px 10px 5px 0px;" />
{l s='You have chosen the cash on delivery method.' mod='visanet'}
<br/><br />
{l s='The total amount of your order is' mod='visanet'}
<span id="amount_{$currencies.0.id_currency}" class="price">{convertPrice price=$total}</span>
{if $use_taxes == 1}
   {l s='(tax incl.)' mod='visanet'}
{/if}
</p>
<p>
<br /><br />
<br /><br />
<b>{l s='Please confirm your order by clicking \'I confirm my order\'' mod='visanet'}.</b>
</p>
<p class="cart_navigation" id="cart_navigation">
<a href="{$link->getPageLink('order', true)}?step=3" class="button_large">{l s='Other payment methods' mod='visanet'}</a>
<input type="submit" value="{l s='I confirm my order' mod='visanet'}" class="exclusive_large" />
</p>
</form>
 

estuve mirando los ejemplos de como invocar una función sin éxito. el ultimo que mire fue:

 

{$a|getCategoryParent()}

 

cuando actualizo la pagina queda en blanco

 

de antemano agradezco su apoyo.

 

desarrollando en prestashop 1.6

 

 

muchas gracias.

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

Hola, Negativo cuando pongo esa sentencia la pagina se queda en blanco.

 

intente con 

 

 

{$this->getCategoryParent()}

 

igual sin poder levantar.

 

Saludos,

A ver, en el controller tienes que asignar la variable, en el initcontent, en el array añades

'function_add' => $this->getCategoryParent(),

y en el .tpl

{$function_add}
Link to comment
Share on other sites

Super, funcionar.

 

ahora me surgio otro inconvenite. no se si abrir otro post :(

 

 

estoy ejecutando un curl

 

 

$curl = curl_init();
 
    echo "<br>";
echo $data;
 
curl_setopt($curl, CURLOPT_POST, 1);
    if ($data)
       curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
 
 
    // Optional Authentication:
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    $credentials = $accessKeyId . ":" . $secretAccessKey;
    echo "<br>";
    echo $credentials;
    curl_setopt($curl, CURLOPT_USERPWD, $credentials);
 
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 
    $headers = array(
        'Content-Type: application/json'  
    );
 
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
 
    echo "<br>";
echo  $headers;
 
    $result = curl_exec($curl);
 
    curl_close($curl);
    echo "<br>";
echo "YEP";
echo "<br>";
echo $curl;
    return $result;
 
 
pero nunca me imprimer la respuesta.
 
no se si es algo de configuración 
 
 
Saludos, y muchas gracias de antemano
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...