- Posts: 165
- Thank you received: 3
Load the Page title in hikashop to a form?
- jschroeder
-
Topic Author
- Offline
-- HikaShop version -- : 2.2.0
-- Joomla version -- : 3.1.5
-- PHP version -- : x.x.x
I want to load the $product_name variable into my form on the page as the default value in the "Price Match Item:" I have tried for a few hours and have not seemed to be able to get it to work. Here is what I have tried below with no success how do i get this to work?
I want the product_name variable for each product to load in this field on every page.
thanks,
Josh
<?php
$db = JFactory::getDbo();
$db->setQuery("SELECT `product_name` FROM `#__hikashop_product` WHERE `product_name`='value' LIMIT 1");
return $db->loadResult();
?>
Please Log in or Create an account to join the conversation.
I don't understand your SQL request.
You want to retrieve the product name but I don't understand for which product.
In your request, you made a search for a specific product_name, so you will retrieve the value "value" if you have a product with this name.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
I want to load the product_name which on this page is "SLEEP-PEDIC - HOTEL FIRM" as the default value for the form field called "price matched item". I attached an image to show you what I am talking about.
I want to do this on all my hikashop product pages. I want the product name to be loaded as the default value in the form for each page. By the way the form field called "price matched item" is a rsformpro field, which is where I want the product name.
I cannot figure out how to do this.
Thanks,
Josh
Please Log in or Create an account to join the conversation.
You can get the product name with the code below on that page:
<?php echo $this->element->product_name; ?>
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
Previously when i had a virtuemart I a code similar to this. I tried modifying it for hikashop but it does not work. I do not fully understand how to do it..
<?php function hikashop_getCID('product_id') {
$id = $_GET["product_id"];
$db = & JFactory::getDBO();
$query = 'SELECT product_name FROM #__hikashop_product ' . ' WHERE product_id = ' . (int) $id;
$db->setQuery($query);
$product_name = $db->loadResult();
echo $product_name;
}
?>
Please Log in or Create an account to join the conversation.
Try like that:
$id =hikashop_getCID('product_id');
$db = & JFactory::getDBO();
$query = 'SELECT product_name FROM #__hikashop_product WHERE product_id = ' . (int) $id;
$db->setQuery($query);
$product_name = $db->loadResult();
echo $product_name;
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
Fatal error: Call to undefined function hikashop_getCID() in administrator/components/com_rsform/helpers/rsform.php(568) : eval()'d code on line 2
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
I inserted the code like this in the default field.
<?php
if(!defined('DS'))
define('DS', DIRECTORY_SEPARATOR);
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
$id =hikashop_getCID('product_id');
$db = & JFactory::getDBO();
$query = 'SELECT product_name FROM #__hikashop_product WHERE product_id = ' . (int) $id;
$db->setQuery($query);
$product_name = $db->loadResult();
echo $product_name;
?>
Also, I have my web developer toolkit and it is throwing the browser into quirks mode.
Josh
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
The script should be similar to :
//<code>
$productId = JRequest::getVar('the_name_of_the_id_parameter_from_the_URL');
$db = JFactory::getDbo();
if ($productId) {
// Grab the value from the database.
$db->setQuery("SELECT `product_name` FROM `#__hikashop_products` WHERE `product_id`='".$productId."'");
return $db->loadResult();
}
//</code>
You will only need to replace 'the_name_of_the_id_parameter_from_the_URL' with the actual parameter from the URL that holds the hikashop product id.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
//<code>
$productId = JRequest::getVar('cid');
$db = JFactory::getDbo();
if ($productId) {
// Grab the value from the database.
$db->setQuery("SELECT `product_name` FROM `#__hikashop_product` WHERE `product_id`='".$productId."'");
$product_name = $db->loadResult();
echo $product_name;
}
//</code>
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
Here is the code i used
//<code>
$productId = JRequest::getVar('cid');
$db = JFactory::getDbo();
if ($productId) {
// Grab the value from the database.
$db->setQuery("SELECT `product_name` FROM `#__hikashop_product` WHERE `product_id`='".$productId."'");
return $db->loadResult();
}
//</code>
Please Log in or Create an account to join the conversation.