Display Product in Custom Article Page

  • Posts: 82
  • Thank you received: 2
  • Hikashop Multisite
6 years 2 months ago #288280

-- HikaShop version -- : 3.3.0
-- Joomla version -- : 3.8.5
-- PHP version -- : 7.1.13
-- Browser(s) name and version -- : Google Chrome 63.0.3239.132

Hi,
I would like to ask how can i display product on the article page since from the script we already have the product ID. We only need to include the product name, price and product quantity.
Can you guys guide me to do this? I can do the scripting just need a guideline to work with this. Thanks.


File Attachment:

File Name: displayproduct.txt
File Size:1 KB

This is part of the script that are used.

Attachments:
Last edit: 6 years 2 months ago by alainz.

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

  • Posts: 12953
  • Thank you received: 1778
6 years 2 months ago #288286

Hello,

Using and eventually modifying the code of "Hikashop product TAG insertion/translation" plugins will probably do the job.
www.hikashop.com/support/documentation/1...-product-insert.html

Best regards,
Mohamed Thelji.

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

  • Posts: 82
  • Thank you received: 2
  • Hikashop Multisite
6 years 2 months ago #288447

Hi,
Why there is no result display when i using the tag format? Or did i do something wrong. Any help i would appreciate it.

jQuery( ".charityHouseTitle" ).load( "/index.php?option=com_content&view=article&id="+ artID + " #title-charity h2" );
//end get quota for each charity
//get need for each charity
jQuery.ajax({
type: "GET",
url: ' ayambrand-com-my-v1.cloudaccess.host/ind...get_need&charity_id= ' + ID,
success: function (data){
"use strict"
console.log('get need for selected charity house : ');
//console.log(ID);
var ac = JSON.parse(data);
var content = '<table class="table table-hover">';
var heading = "<tr>";
var datas = "";
var remaining_quota='';
var product_id='';
var quota = '';

heading += '<th>' + 'Product' + '</th>' + '<th>' + 'Quantity Need' + '</th>' + '<th>' + 'Price Each' + '</th>' + '<th>' + 'My Donation' + '</th>' + '<th>' + 'Amount' + '</th>';
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);
});
var productLink = '{product}' + product_id + '|name|cart|quantityfield|link|pricedis3|pricetax1{/product}';

datas += "<tr>";
datas += '<td>' + productLink + '</td>' + '<td>' + remaining_quota + '</td>' ;
datas += "</tr>";
});
});
heading += "</tr>";
content += heading + datas + "</table>";
jQuery('#content').append(content);
}

The url will provide this data in JSON format where product id are link to Hikashop product.
{
    "3": {
        "id": "3",
        "state": "1",
        "charity_id": "3",
        "unmet_quotas": {
            "product_quotas1": {
                "product_id": "134",
                "quota": "32",
                "remaining_quota": "32",
                "progress": 0,
                "vegetarian": "0"
            },
            "product_quotas2": {
                "product_id": "153",
                "quota": "12",
                "remaining_quota": "12",
                "progress": 0,
                "vegetarian": "1"
            },
            "product_quotas3": {
                "product_id": "148",
                "quota": "10",
                "remaining_quota": "10",
                "progress": 0,
                "vegetarian": "0"
            },
            "product_quotas4": {
                "product_id": "165",
                "quota": "10",
                "remaining_quota": "10",
                "progress": 0,
                "vegetarian": "0"
            },
            "product_quotas5": {
                "product_id": "310",
                "quota": "8",
                "remaining_quota": "8",
                "progress": 0,
                "vegetarian": "0"
            }
        }
    }
}

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
6 years 2 months ago #288456

Hi,

I think that mohamed didn't understand what you were trying to do.
You can't use the content tag system to get any data from the product with dynamic javascript.
The content tag system is replacing the tags on your website at the end of the page processing on the server side.
Generating tags dynamically in javascript on the client side won't do anything.

And there is no URL you can call in AJAX to get information from a product in your javascript.
So what you need is to write a small plugin using the AJAX system of Joomla:
docs.joomla.org/Using_Joomla_Ajax_Interface
In that plugin, implement a function to get the data of the product from the hikashop_product table with a small MySQL query based on a product_id passed through the URL of the AJAX call and return back the data in json.
Then, you can cal that URL in AJAX in your javascript to get the data you need.

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

Time to create page: 0.077 seconds
Powered by Kunena Forum