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

{RESOLVED} approach to parsing product_attributes for line item

Started by swheeler, July 17, 2014, 17:27:45 PM

Previous topic - Next topic

swheeler

Hi,

<span class="costumTitle">Size</span><span class="costumValue" >Medium</span>

This is actually the text representation component of a VirtueMart order line that is stored in JSON array format in 'product_attributes' column in the 'order_items' table.  I am attempting to parse out the value of 'Medium' for the 'costumValue' class.  So far, I've been using the following code without any success:

       $dom = $dom = new DOMDocument();
                     
              $dom->load($val);      // where $val is the text represented above.
              $finder = new DomXPath($dom);
              $classname = "costumValue";
              $nodes = $finder->query("//*[contains(@class, '$classname')]");
              //echo $nodes->item(0)->nodeValue . "\n";
              //echo $nodes->nodeValue . "\n";
              echo $nodes->childNodes . "\n";

Any recommendations?

Thanks,
Scott