- Posts: 69
- Thank you received: 1
How to include Hikashop environment in RSForms
- dkmetz@taylorbruce.com
-
Topic Author
- Offline
Less
More
11 years 4 months ago - 11 years 4 months ago #202344
by dkmetz@taylorbruce.com
______________
Dennis Kmetz
-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.5.17
-- Error-message(debug-mod must be tuned on) -- : Notice: Trying to get property of non-object in /home/steineri/public_html/administrator/components/com_rsform/helpers/rsform.php(552) : eval()'d code on line 43
Hi,
I am writing a RSForms PHP script and would like to access the Hikashop classes/helpers. I cannot seem to get things to work. Here is the code I am having an issue with:
and this is the result page:
I am not able to get the product_id value. Can you please tell me what I am doing wrong?
Dennis
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.5.17
-- Error-message(debug-mod must be tuned on) -- : Notice: Trying to get property of non-object in /home/steineri/public_html/administrator/components/com_rsform/helpers/rsform.php(552) : eval()'d code on line 43
Hi,
I am writing a RSForms PHP script and would like to access the Hikashop classes/helpers. I cannot seem to get things to work. Here is the code I am having an issue with:
Code:
echo ("1 about to include ===> ".JPATH_ADMINISTRATOR . DS . 'components/com_hikashop/helpers/helper.php' . "<br />");
include(JPATH_ADMINISTRATOR . DS . 'components/com_hikashop/helpers/helper.php');
if (!class_exists('hikashop')) {
echo ("2 about to include ===> ".JPATH_ADMINISTRATOR . DS . 'components/com_hikashop/helpers/helper.php' . "<br />");
include(JPATH_ADMINISTRATOR . DS . 'components/com_hikashop/helpers/helper.php');
}
if (!class_exists('hikashopProductClass')) {
echo ("3 about to include===> " . JPATH_ADMINISTRATOR . DS . 'components/com_hikashop/classes/product.php' . "<br />");
include(JPATH_ADMINISTRATOR . DS . 'components/com_hikashop/classes/product.php');
}
if (class_exists('hikashop')) echo ("1a hikashop class is available! <br />");
if (class_exists('hikashopProductClass')) echo ("3a hikashopProductClass class is available! <br />");
$pid = $jinput->get('cid', 'default_value', 'raw');
echo ("pid is " . $pid);
$productClass = hikashop_get('class.product');
$productID = $productClass->get($pid->product_id);
echo ("Product ID is ==>" . $productID );
return $productID ;
and this is the result page:
1 about to include ===> /home/steineri/public_html/administrator/components/com_hikashop/helpers/helper.php
3 about to include===> /home/steineri/public_html/administrator/components/com_hikashop/classes/product.php
1a hikashop class is available!
3a hikashopProductClass class is available!
pid is 1095
Notice: Trying to get property of non-object in /home/steineri/public_html/administrator/components/com_rsform/helpers/rsform.php(552) : eval()'d code on line 43
Product ID is ==>1
I am not able to get the product_id value. Can you please tell me what I am doing wrong?
Dennis
______________
Dennis Kmetz
Last edit: 11 years 4 months ago by dkmetz@taylorbruce.com. Reason: forgot last few lines of code
Please Log in or Create an account to join the conversation.
11 years 4 months ago - 11 years 4 months ago #202361
by nicolas
Replied by nicolas on topic How to include Hikashop environment in RSForms
In your code you have the line:
echo ("pid is " . $pid);
And it displays as:
pid is 1095
So $pid is an integer.
Then, you have the line:
$productID = $productClass->get($pid->product_id);
where you use $pid as if it was an object with an attribute called "product_id" in it.
You probably want to write instead:
$productID = $productClass->get($pid);
Also note that the return of the get function of the product class is an object with all the data of the product and not an int/string, so you can't just echo it like you do on the next line.
echo ("pid is " . $pid);
And it displays as:
pid is 1095
So $pid is an integer.
Then, you have the line:
$productID = $productClass->get($pid->product_id);
where you use $pid as if it was an object with an attribute called "product_id" in it.
You probably want to write instead:
$productID = $productClass->get($pid);
Also note that the return of the get function of the product class is an object with all the data of the product and not an int/string, so you can't just echo it like you do on the next line.
Last edit: 11 years 4 months ago by nicolas.
Please Log in or Create an account to join the conversation.
9 years 4 months ago #269525
by Bobwales
Replied by Bobwales on topic How to include Hikashop environment in RSForms
Don't want to hijack this thread, but have a requirement to use RSForms in product descriptions.
By inserting code similar to
{rsform 1}
inside any article text, including the description text field of a Hikashop product, displays the form.
And that form can be pre-populated using similar to
{rsform 1 fieldName="fieldValue" textbox="textboxValue" radioGroup="someValue" checkbox="cat" checkbox="dog"}
I'd like to pre-populate the form with the current product price. (In my case the form will illustrate the finance terms of our bikes when purchased on credit).
Is there a way to do this using this simple format? A bit like {rsform 1 bikeprice="<script>some php code that extracts current price</script>}
I don't really want to edit the View that we use as not all products would be appropriate to the form. It would be more manageable to insert the form into a product description.
Help or ideas would be much appreciated.
By inserting code similar to
{rsform 1}
inside any article text, including the description text field of a Hikashop product, displays the form.
And that form can be pre-populated using similar to
{rsform 1 fieldName="fieldValue" textbox="textboxValue" radioGroup="someValue" checkbox="cat" checkbox="dog"}
I'd like to pre-populate the form with the current product price. (In my case the form will illustrate the finance terms of our bikes when purchased on credit).
Is there a way to do this using this simple format? A bit like {rsform 1 bikeprice="<script>some php code that extracts current price</script>}
I don't really want to edit the View that we use as not all products would be appropriate to the form. It would be more manageable to insert the form into a product description.
Help or ideas would be much appreciated.
Please Log in or Create an account to join the conversation.
9 years 4 months ago #269527
by nicolas
Replied by nicolas on topic How to include Hikashop environment in RSForms
Hi,
I don't see a way to do it without modifying the view. I'm however not familiar with RSForms.
Also, based on how your product page is customized, you might have a problem with the RSForms form being inside the product page main form. Because having a form in a form is not valid in HTML.
I don't see a way to do it without modifying the view. I'm however not familiar with RSForms.
Also, based on how your product page is customized, you might have a problem with the RSForms form being inside the product page main form. Because having a form in a form is not valid in HTML.
Please Log in or Create an account to join the conversation.
Time to create page: 0.203 seconds