Reputation: 65
I have this XML here: https://www.bazakas.gr/ProductsXML, which I am importing into Woocommerce, where on some products there is the value for weight, which I want to use for the products, under the attributes / attribute / value. The problem is that on some products that value is under {attributes[1]/attribute[18]/value[1]} i.e. on the first product and on some others its under {attributes[1]/attribute[16]/value[1]}.
Reading the documentation I created the following simple function:
<?php
function get_weight ($title, $value){
if ($title = "Καθαρό βάρος (Kg)") {
return $value;}
}
?>
which basicallly returns the attiblute value when the attribute title is "Καθαρό βάρος (Kg)" The problem is that I cannot use something like [get_weight ({attributes[x]}, {attributes[x]/value[x]} )] into the weight field of the product. Is there another implementation that I can use to do what I want? How can I get the value of attribute when the attribute title is "Καθαρό βάρος (Kg)". Please explain all needed steps. Thanks
Upvotes: 0
Views: 78
Reputation: 65
After talking to the WP All Import support I got my solution which was very simple but I couldn't find searching on the web. In order to get the value I used the following string on the product weight field of the Woocommerce Add-on for WP All Import : {attributes[1]/attribute[title = "Καθαρό βάρος (Kg)"]/value[1]} That takes the value under the Arribute with title "Καθαρό βάρος (Kg)". It's documented under the XPath Cheat Sheet here : https://www.wpallimport.com/documentation/custom-xpath/#cheat-sheet, where you can find other solutions related to this.
I couldn't have found it. Their support is amazing !!!
Upvotes: 0