Add to cart only work with default characteristics

  • Posts: 39
  • Thank you received: 0
10 years 7 months ago #187107

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.2.4
-- PHP version -- : 5.4.32
-- Browser(s) name and version -- : Opera 26.0

I have upgraded my site from Hika 2.3.0 to 2.3.5 and am rebuilding my products. II have meal products with three characteristic ingredients (meat, carb, veg). At the moment i can add a meal to cart only if it's default (the first options available in each drop down list) characteristics are chosen. If I select any other options and add to cart it appears the meal is not added to cart. Any help would be appreciated. I have attached screen caps of meal product config and variant config (most variants are $0 pricing, some have a price which is Main product price percentage set 10 100%)

Attachments:

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

  • Posts: 26274
  • Thank you received: 4045
  • MODERATOR
10 years 7 months ago #187127

Hi,

I am sorry but we will need a lot more information to understand your problem.
A link to your store would be a good start. But we also need to understand your HikaShop configuration, know your settings, know the different variants of a product (on just one single variant, it's not enough).
We also need to know if you got some error message while adding the product, if you got some javascript errors, if you have some override views, if you modified some hikashop core file, etc.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 39
  • Thank you received: 0
10 years 7 months ago #187252

Hi sorry it slipped my mind to supply further details. Unfortunately the site is being built on a dev server in private network so I can't provide a link.

I am however, getting a javascript error (which I didn't think of checking for) and I have modded some hikashop views (I have attached files).

The javascript error is: Uncaught TypeError: undefined is not a function (anonymous function)

in this section of script (error is flagged on last line of snipppet)

<!--
var hikashopFieldsJs=Array();
hikashopFieldsJs=Array();
hikashopFieldsJs=Array();
//-->

<!--

function hikashopToggleFields(new_value,namekey,field_type,id,prefix){
var arr = new Array();
var checked = 0;
arr = document.getElementsByName('data[]');
if(typeof arr[0] != 'undefined' && typeof arr[0].length != 'undefined'){
var size = arr[0].length;
}else{
var size = arr.length;
}
if(prefix === undefined || !prefix || prefix.length == 0 || prefix.substr(-1) != '_')
prefix = 'hikashop_';
for(var c = 0; c < size; c++){
if(typeof arr[0] != 'undefined' && typeof arr[0].length != 'undefined'){
var obj = document.getElementsByName('data[]').item(0).item(c);
}else{
var obj = document.getElementsByName('data[]').item(c);
}
if((typeof obj.checked != 'undefined' && obj.checked) || (typeof obj.selected != 'undefined' && obj.selected)){
checked++;
}
if((typeof obj.type != 'undefined' && obj.type=='checkbox')){
var specialField = true;
}
}
var checkedGood = 0;
var count = 0;
if(typeof hikashopFieldsJs != 'undefined' && typeof hikashopFieldsJs[field_type] != 'undefined'){
for(var k in hikashopFieldsJs[field_type][namekey]) {
if(typeof hikashopFieldsJs[field_type][namekey][k] == 'object'){
for(var l in hikashopFieldsJs[field_type][namekey][k]){
if(typeof hikashopFieldsJs[field_type][namekey][k][l] == 'string'){
count++;
newEl = document.getElementById(namekey+'_'+k);
if(newEl && ((typeof newEl.checked != 'undefined' && newEl.checked) || (typeof newEl.selected != 'undefined' && newEl.selected))){
checkedGood++;
}
}
}
}
}
}
if(typeof arr[0] != 'undefined' && typeof arr[0].length != 'undefined' && count>1){
var specialField = true;
}
if(typeof hikashopFieldsJs != 'undefined' && typeof hikashopFieldsJs[field_type] != 'undefined'){
for(var j in hikashopFieldsJs[field_type][namekey]) {
if(typeof hikashopFieldsJs[field_type][namekey][j] == 'object'){
for(var i in hikashopFieldsJs[field_type][namekey][j]){
if(typeof hikashopFieldsJs[field_type][namekey][j] == 'string'){
var elementName = prefix+field_type+'_'+hikashopFieldsJs[field_type][namekey][j];
if(id){
elementName = elementName + '_' + id;
}
el = document.getElementById(elementName);
if(!el) continue;
if(specialField){
if(checkedGood==count && checkedGood==checked && new_value!=''){
el.style.display='';
hikashopToggleFields(el.value,hikashopFieldsJs[field_type][namekey][j],field_type,id,prefix);
}else{
el.style.display='none';
hikashopToggleFields('',hikashopFieldsJs[field_type][namekey][j],field_type,id,prefix);
}
}else{
if(j==new_value){
el.style.display='';
hikashopToggleFields(el.value,hikashopFieldsJs[field_type][namekey][j],field_type,id,prefix);
}else{
el.style.display='none';
hikashopToggleFields('',hikashopFieldsJs[field_type][namekey][j],field_type,id,prefix);
}
}
}
}
}
}
}
}

I needed to change the layout of product/show_default view and added some div and a link in the 'show_default_div' section of product/show_quantity


In the product/show_default view I modded hikashop_product_top_part div duplicated the hikashop_product_description_main div to make it appear in both left_part and right_part divs (I need two different types product description info to appear in left and right divs respectively so I enter the info into product description but display it twice using css to show only the part needed for left_part or right_part divs). I also moved the hikashop_product_quantity_main div to the bottom of the view.

Attachments:
Last edit: 10 years 7 months ago by dda. Reason: Added extra info

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 7 months ago #187324

Hi,

It would be better to be able to look at the HTML/JS directly on the page so that we could do some debugging.
Nevertheless, from what I understand, the issue comes from the customizations that were made to the files of the product view, preventing the HikaShop javascript from finding the necessary elements on the page for the add to cart to work properly.
Try to rename the folder templates/YOUR_TEMPLATES/html/com_hikashop/product to something else via FTP in order to temporarily disable the view files overrides and see if that helps. Normally, it should solve the problem.
So in that case, I would recommend first to identify the exact file with the issue with the same method applied to each file of that folder.
Then, reapply your modifications to the new version of the file making sure that the characteristics/add to cart system is not broken after each modification.

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

  • Posts: 39
  • Thank you received: 0
10 years 7 months ago #188468

I didn't think to check my view mods. It was caused by something show_default product view (I don't know what though). I redid my modifications and it started working again.

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

Time to create page: 0.068 seconds
Powered by Kunena Forum