Jump to content

Modulo "Enviar una pregunta" relacionada con el producto.


BAZOCA

Recommended Posts

Hola justo debajo del formulario aparece el típico botón de "Volver al producto"

Pues bien cuando haces click te lleva a esto: (cambio el nombre de mi página en el ejemplo por "midominio")

http://www.midomino.es/http:www.midominio.esproduct.php?id_product=58

Creo que debe de haber algo repetido o duplicado en el .php del módulo pero por más que miro no logro indentificarlo.
Si sirve de ayuda sólo sobra el segundo "http:www.midominio.es"
Dejo el código aquí. Gracias.

<?php

class productquestion extends Module
{

   //Configuration::get('PS_SHOP_EMAIL')

    function __construct()
    {
         $this->name = 'productquestion';
         $this->version = '1.1';
         $this->tab = 'Products';

       parent::__construct();
       $this->page = basename(__FILE__, '.php');
       $this->displayName = $this->l('Send to Own Question');
       $this->description = $this->l('This modulo allow send questions about products.');
    }

   function install()
   {
        if (!parent::install())
            return false;
        return $this->registerHook('extraLeft');
   }

   function hookExtraLeft($params)
   {
       global $smarty;
       $smarty->assign('this_path', $this->_path);
       return $this->display(__FILE__, 'product_page.tpl');
   }

   public function displayFrontForm()
   {
       global $smarty;
       $error = false;
       $confirm = false;

       if (isset($_POST['submitQuestion']))
       {
           global $cookie, $link;
           /* Product informations */
           $product         = new Product(intval(Tools::getValue('id_product')), false, intval($cookie->id_lang));
           $productLink     = $link->getProductLink($product);
           $backToProduct     = ''.$this->l('Back to').' "'.$product->name.'"';
           $smarty->assign('backToProduct', $backToProduct);




           /* Fields verifications */
           if (!$cookie->logged && empty($_POST['email']) OR !$cookie->logged && empty($_POST['name']) OR !$cookie->logged && empty($_POST['message']) )
               $error = $this->l('You must fill all fields.');
           elseif (!$cookie->logged AND !Validate::isEmail($_POST['email']))
               $error = $this->l('Your email is invalid.');
           elseif (!$cookie->logged AND !Validate::isName($_POST['name']))
               $error = $this->l('Your name is invalid.');
           elseif (!isset($_GET['id_product']) OR !is_numeric($_GET['id_product']))
               $error = $this->l('An error occurred during the process.');
           else
           {
               /* Email generation */
               $subject = ($cookie->customer_firstname ? $cookie->customer_firstname.' '.$cookie->customer_lastname : $this->l('A customer')).' '.$this->l('send question about').' '.$product->name;
               $templateVars = array(
                   '{product}'      => $product->name,
                   '{product_link}' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').$productLink,
                   '{customer}'      => ($cookie->customer_firstname ? $cookie->customer_firstname.' '.$cookie->customer_lastname : $this->l('A visitor')),
                   '{name}'          => ($cookie->customer_firstname ? $cookie->customer_firstname.' '.$cookie->customer_lastname : Tools::safeOutput($_POST['name']) ),
                   '{email}'         => ($cookie->email ? $cookie->email : Tools::safeOutput($_POST['email']) ),
                   '{message}'         => $_POST['message']

               );

               /* Email sending */
               if (!Mail::Send(intval($cookie->id_lang), 'send_question', $subject, $templateVars, Configuration::get('PS_SHOP_EMAIL'), NULL, NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'))
                   $error         = $this->l('An error occurred during the process.');
               else
                   $confirm     = $this->l('An email has been sent successfully!');
           }
       }
       else
       {
           global $cookie, $link;
           /* Product informations */
           $product = new Product(intval(Tools::getValue('id_product')), false, intval($cookie->id_lang));
           $productLink = $link->getProductLink($product);
       }

       /* Image */
       $images = $product->getImages(intval($cookie->id_lang));
       foreach ($images AS $k => $image)
           if ($image['cover'])
           {
               $cover['id_image'] = intval($product->id).'-'.intval($image['id_image']);
               $cover['legend'] = $image['legend'];
           }

       if (!isset($cover))
           $cover = array('id_image' => Language::getIsoById(intval($cookie->id_lang)).'-default', 'legend' => 'No picture');

       $smarty->assign(array(
           'validate_login' => $cookie->logged,
           'cover' => $cover,
           'errors' => $error,
           'confirm' => $confirm,
           'product' => $product,
           'productLink' => '/'.str_replace('/','',$productLink) 
       ));

       return $this->display(__FILE__, 'productquestion.tpl');
   }
}
?>



Intuyo que el error tiene que ir por aquí que es dónde se hace mención a algo relacionado con "volver a".


$productLink     = $link->getProductLink($product);
           $backToProduct     = ''.$this->l('Back to').' "'.$product->name.'"';
           $smarty->assign('backToProduct', $backToProduct);



A ver alguien observador que lo identifique ! Gracias !

Link to comment
Share on other sites

  • 8 months later...

Hola.

A mi me pasaba lo mismo. Por si aún lo necesitas:

En la línea 75, donde pone esto:

'{product_link}' => htmlspecialchars($productLink), // 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').$productLink,



Tienes que poner esto:

                    '{product_link}' => $productLink,



Saludos.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...