Convert ID to Name

  • Posts: 81
  • Thank you received: 2
  • Hikashop Multisite
6 years 1 week ago #291133

-- HikaShop version -- : 3.4.0
-- Joomla version -- : 3.8.6
-- PHP version -- : 7.1.15
-- Browser(s) name and version -- : Firefox Developer Edition
-- Error-message(debug-mod must be tuned on) -- : No error message.

Hi,
I'm try to change the product ID to product name in HikaShop. The product ID we getting by calling from the custom script.
Here is the part to calling the product ID.

function getCharityNeed(generateID){
	jQuery.ajax({
		type: "GET",
    	url: "http://ayambrand-com-my-v1.cloudaccess.host/administrator/index.php?option=com_echarity&format=raw&task=api.get_need&charity_id=" + generateID,
    	success: function (data){
			var ac = JSON.parse(data);
    		var remaining_quota='';
    		var product_id='';
    		var quota = '';
			jQuery.each(ac, function(index, value) {
				jQuery.each(value.unmet_quotas, function(subindex, subvalue) {
					jQuery.each(subvalue, function(subsubindex, subsubvalue){
						remaining_quota = subvalue.remaining_quota;
    					product_id = subvalue.product_id;
    					quota = subvalue.quota;
						console.log('Product ID : ' + product_id +' Quota : ' + quota + ' Remaining Quota : ' + remaining_quota);
						jQuery.ajax({
							type: "POST",
							url: "/administrator/custom/get_products.php",
							data: {productPost: product_id},
							success: function(data) {
								console.log(data);
								jQuery("#contentNeed").html('<ul><li>'+data+'</li></ul>');    
							}
						});
						return false;
					});
				});
			});
		}
	});
	jQuery(".pTitles").load( "/index.php?option=com_content&view=article&id="+ generateArticleID + " #title-charity h2" );
}

The other part is the php file where we pass the variable to php and trying to convert the ID to the product name.
<?php
if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){
	return false; 
}
if(isset($_POST['productPost'])){
	$productClass = hikashop_get('class.product');
	$productID = $_POST['productPost'];
	$product=$productClass->get($productID);
	echo "Product ID : " + $product;
}
?>

But the issue is it not return any results to the main page. But if i remove all the php/hikashop script it return something on the main page.
Can you help me to configure it.
Thans in advnces.

Last edit: 6 years 1 week ago by alainz.

Please Log in or Create an account to join the conversation.

  • Posts: 81478
  • Thank you received: 13062
  • MODERATOR
6 years 1 week ago #291148

Hi,

The file JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php' is supposed to be called once Joomla is already loaded.
If you don't load Joomla before, then it can't work properly.
Even the first piece, JPATH_ADMINISTRATOR, is a joomla constant. If Joomla is not initialized first, this constant doesn't exist and thus HikaShop's helper file path will be wrong.
So I think it comes from that.

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 2
  • Hikashop Multisite
6 years 1 week ago #291179

Hi,

Btw do you mean this script i need to include in the external php file so it will be like below?

<?php
define('_JEXEC', 1);
define('JPATH_BASE', '../');
require_once JPATH_BASE . 'includes/defines.php';
require_once JPATH_BASE . 'includes/framework.php';

// Create the Application
$app = JFactory::getApplication('site');

if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){
	return false; 
}
if(isset($_POST['productPost'])){
	$productClass = hikashop_get('class.product');
	$productID = $_POST['productPost'];
	$product=$productClass->get($productID);
	echo "Product ID : " + $product;
}
?>

Please correct me if I'm wrong.
Thanks.

Last edit: 6 years 1 week ago by alainz.

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 2
  • Hikashop Multisite
6 years 6 days ago #291191

Hi,

Nevermind, just ignore the reply before. Already found some solutions.

Thanks.

Please Log in or Create an account to join the conversation.

Time to create page: 0.062 seconds
Powered by Kunena Forum