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"
}
}
}
}