• Resolved kpeet

    (@kpeet-1)


    Hi all,

    I try to parse the sku of an order in Woocommerce based on the quantity.
    So for example,

    If someone ordered 1X item_X and 2x item_Y
    My custom XML is:

    	<products>
    		<artnr>{sku}</artnr>
    		<Quantity>{Quantity}</Quantity>
    	</products>

    the output now in my xml is (based on above):

    <products>
    <artnr>
    Item_X
    </artnr>
    <artnr>
    Item_Y
    </artnr>
    <Quantity>
    1
    </Quantity>
    <Quantity>
    2
    </Quantity>
    </products>

    But i would like to have an output in XML like:

    <products>
    <artnr>
    Item_X
    </artnr>
    <artnr>
    Item_Y
    </artnr>
    <artnr>
    Item_Y
    </artnr>
    </products>

    So an output one Item_x and two times Item_Y

    I tried to do something like:
    Or can i beter use functions, or create the export in a different way?
    <artnr>[FOREACH({Quantity})]{@SKU}[ENDFOREACH]</artnr>

    Hope you guys can help me out ??

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter kpeet

    (@kpeet-1)

    Or use something like (found on the web), and needs to customize for this function

    function aantal_product_sku($sku) {
    foreach ($sku as $item) {
      echo "$item\n";
      $sku[] = $item;
    }
    print_r($sku);
    }
    • This reply was modified 5 years ago by kpeet.
    Plugin Author WP All Import

    (@wpallimport)

    Hi @kpeet-1

    So an output one Item_x and two times Item_Y

    You’ll have to write some custom code to do that. This guide should point you in the right direction as it shows you how to programmatically access the products and quantities and create custom output: https://gist.github.com/trey8611/ef75ab0b080115efab5ce0fee1d5dcbd.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Parse Sku (per row) depending on quantity XML output Orders Woocommerce’ is closed to new replies.