Forums

Custom Element in Virtuemart

insightcreative 01 Mar, 2014
Hi

From another post I read about adding a custom element to read in a variable from a URL using GET. This worked fine but I've moved on a bit and now I'm stuck.

On this page:
http://www.staffstuff.co.uk/2014-03-01-13-39-26/emboidered-polo-shirts/budget-short-sleeve-embroidered-polo-detail

There is an Enquire button just below the image. This opens a chronoform and puts the product name in the top. That's fine.

BUT...

I want to get rid of this and have put the form into a tab called Enquire.

The form displays nicely so I'm happy with that. However, it won't display the product name as it's not a variable in the URL.

The PHP on the page that displays the product has this:

<?php echo $this->product->product_name ?>

So, my question is how I get the product name into a field in the form.

Any help would be gratefully received!

Regards
Andy
insightcreative 01 Mar, 2014
Just noticed the URL is wrong! Should be:

http://www.staffstuff.co.uk/embroidered-workwear/emboidered-polo-shirts/budget-short-sleeve-embroidered-polo-detail#enquire

I've moved on a little bit in as much as it's displaying the URL of the referring page. I can live with that if I can hide it from the visitor somehow. However, that field isn't coming out in the e-mail.
insightcreative 02 Mar, 2014
Fixed but dirty!

<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}

?>
<?php
$form->data['product_name'] = curPageURL();
?>

Then just have a hidden field with product_name set as the value.

It doesn't give me exactly what I want but at least I'll know what page the user was on when they filled in the form.
This topic is locked and no more replies can be posted.