News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Missing values in custom fields

Started by iMilazzo, August 19, 2012, 20:53:39 PM

Previous topic - Next topic

iMilazzo

Good morning! (this is a google translator)

I'm trying to do a shop for selling screws, tools using Virtuemart but certain bolts have a wide variety of sizes resulting in a large amount of child products. It seems that Virtuemart does not like many products children and just "disappearing" with some measures that are registered in the system. The specific missing measures are 2, 3 and 4 inches (length) for all of my diameters!

This is an strech of javascript in the website:

var stockable = jQuery.parseJSON('{
"2213":{"selectoptions1":["1","1"],"selectoptions2":["1 1\/2","1 1\/2"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":78},
"2214":{"selectoptions1":["1","1"],"selectoptions2":["1 3\/4","1 3\/4"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":0},
"2215":{"selectoptions1":["1","1"],"selectoptions2":["10","10"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":10},
"2216":{"selectoptions1":["1","1"],"selectoptions2":["11","11"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":0},
"2217":{"selectoptions1":["1","1"],"selectoptions2":["12 1\/2","12 1\/2"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":0},
"2218":{"selectoptions1":["1","1"],"selectoptions2":["2","2"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":206},
"2219":{"selectoptions1":["1","1"],"selectoptions2":["2 1\/2","2 1\/2"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":77},
"2220":{"selectoptions1":["1","1"],"selectoptions2":["2 1\/4","2 1\/4"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":136},
"2221":{"selectoptions1":["1","1"],"selectoptions2":["2 3\/4","2 3\/4"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":0},
"2222":{"selectoptions1":["1","1"],"selectoptions2":["3","3"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":1},
"2223":{"selectoptions1":["1","1"],"selectoptions2":["3 1\/2","3 1\/2"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":88},
"2224":{"selectoptions1":["1","1"],"selectoptions2":["3 3\/4","3 3\/4"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":0},
"2225":{"selectoptions1":["1","1"],"selectoptions2":["4","4"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":15},
"2226":{"selectoptions1":["1","1"],"selectoptions2":["4 1\/2","4 1\/2"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":14},
"2227":{"selectoptions1":["1","1"],"selectoptions2":["5","5"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":26},
"2228":{"selectoptions1":["1","1"],"selectoptions2":["5 1\/2","5 1\/2"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":10},
"2229":{"selectoptions1":["1","1"],"selectoptions2":["5 1\/4","5 1\/4"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":0},
"2230":{"selectoptions1":["1","1"],"selectoptions2":["6","6"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":19},
"2231":{"selectoptions1":["1","1"],"selectoptions2":["6 1\/2","6 1\/2"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":0},
"2232":{"selectoptions1":["1","1"],"selectoptions2":["7","7"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":0},
"2233":{"selectoptions1":["1","1"],"selectoptions2":["8","8"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":28},
"2234":{"selectoptions1":["1","1"],"selectoptions2":["8 1\/2","8 1\/2"],"selectoptions3":["Oxidado e Oleado","Oxidado e Oleado"],"in_stock":0},


as u can see, the product 2218, 2222 and 2225 are in the JSON but i can't see this products on the dropdown box!



By imilazzo at 2012-08-19



By imilazzo at 2012-08-19

Please help me, I really want to use Virtuemart, but it to work fine, this way I can't use it! I need to know what am I doing wrong or I will need to find another Joomla! store!

Thank
Ivan Milazzotti

ps: and yes...this is the same topic twice...

[attachment cleanup by admin]

iMilazzo

#1
I've found the code where this error is occuring:

function populateNextSelect(child_attrib, nextIndex) {
   var nextSelect = jQuery("#selectoptions"+nextIndex);
   if (nextSelect.length > 0) {
      if (jQuery("#selectoptions"+nextIndex+" option:contains(" + child_attrib["selectoptions"+nextIndex][0] + ")").length == 0) {
         nextSelect.append("<option value='" + child_attrib["selectoptions"+nextIndex][0] + "'>" + child_attrib["selectoptions"+nextIndex][1] + "</option>");
      }
      if (1 == jQuery("#selectoptions"+nextIndex+" option").length) {
         jQuery("#selectoptions"+nextIndex+" option").attr("selected","selected");
         selections[nextIndex] = child_attrib["selectoptions"+nextIndex][0];
         populateNextSelect(child_attrib, nextIndex+1);
         }
   }
}
      });
But i don't know the best way to fix it!
This "option:contains"  is telliing me that "2 1/4 inches" is equal "2 inches" beacause 2 1/4 "contains" 2 !!!! :-[

iMilazzo

I think I fixed, changing option:contains to option[text='text']:


function populateNextSelect(child_attrib, nextIndex) {
   var nextSelect = jQuery("#selectoptions"+nextIndex);
   if (nextSelect.length > 0) {
      if (jQuery("#selectoptions"+nextIndex+" option[text='" + child_attrib["selectoptions"+nextIndex][0] + "']").length == 0) {
         nextSelect.append("<option value='" + child_attrib["selectoptions"+nextIndex][0] + "'>" + child_attrib["selectoptions"+nextIndex][1] + "</option>");
      }
      if (1 == jQuery("#selectoptions"+nextIndex+" option").length) {
         jQuery("#selectoptions"+nextIndex+" option").attr("selected","selected");
         selections[nextIndex] = child_attrib["selectoptions"+nextIndex][0];
         populateNextSelect(child_attrib, nextIndex+1);
      }
   }
}
});

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

iMilazzo

Quote from: Milbo on August 20, 2012, 13:04:56 PM
Thank you, very good work.

Milbo, do I need to change any other places? This modification will be part of the core in future versions?


Thank you!
Ivan Milazzotti

Milbo

LoL, btw, my examen was writing a programm for screws and bolts.

In your case I would do it different. And why stockable? Most screws are sold in kg.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

iMilazzo

Well,  I don't know anything about Virtuemart yet and I don't know what are my best options. If u have any suggestions (anything) just tell me !!!

This is the site (very experimental yet) : www.jmparafusos.com.br/jm

Be my guest, say whatever you want!


Thank u
Ivan Milazzotti

natax

Dear  iMilazzo,

THANK YOU for sharing this it was very helpful for me.  :)
Any ideas how to manage the order of child's ???
i am a beginner, so any suggestion will be great !

thanks in advance