2

My intention is to send the sku as a hidden variable when applying for the contact form but only after having visited a product.

It works fine with localhost, where the cache is disabled, but not with the online website because it only gets the information the first time I access to the contact page and when I access from another product it maintains the previous sku. It only works when I refresh the cache but it's really strange in my opinion.

Here is the code I have for form.phtml

<?php
    if(isset($_GET['sku'])) 
    {
        $print_text = $_GET['sku'];
    }
    else
    {
        $print_text = "";
    }
?>
<input type="hidden" value="<?php echo $print_text ?>" name="sku" id="sku" title="<?php echo Mage::helper('contacts')->__('Sku') ?>"/>

And this for view.phtml

<p>Para cantidades inferiores o informaci&oacute;n <a href="http://example.com/contacto/?sku=<?php echo $_product->getSku() ?>">consultar</a></p>

And I get the information from the admin panel, transactional emails. Adding this at the end of the contact form:

<p>Sku: {{var data.sku}}</p>

How can I get the information without having to refresh cache the whole time?

1

Better idea to use this code for getting sku

$print_text=Mage::app()->getRequest()->getParam('sku');

I guess your contacts us url may be http://example.com/contacts instead of http://example.com/contacto

  • Same thing happens. After changing $_GET['sku'] to Mage::app()->getRequest()->getParam('sku') it still has the same value it had before, it doesn't change after having changed the parameter, only if chache is refreshed... :/ Thanks for your help anyway, and what you mentioned about contacts instead of contacto both work – danibg Jun 17 '15 at 11:55
  • Never mind, you were right, even when contacto and contacts redirect to the same form, if I put contacts on the link instead of contacto the parameter returns the information correctly. – danibg Jun 17 '15 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.