Jump to content

1.7 How to get cart_rows sort by date_add Webservice Api


Conselio

Recommended Posts

Hi,

When I call :

<?php 
            $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
            $opt['resource'] = 'carts';
            $opt['id'] = (int)8; // cast string => int for security measures
            // Call
            $xml = $webService->get($opt);
            // Here we get the elements from children of customer markup which is children of prestashop root markup
            $resources = $xml->children()->children();

I get :

<CART_ROWS nodeType="cart_row" virtualEntity="true">
	<CART_ROW>
	<ID_PRODUCT xlink:href="https://myshop.com/api/products/1"><![CDATA[1]]></ID_PRODUCT>
	<ID_PRODUCT_ATTRIBUTE xlink:href="https://myshop.com/api/combinations/0"><![CDATA[0]]></ID_PRODUCT_ATTRIBUTE>
	<ID_ADDRESS_DELIVERY xlink:href="https://myshop.com/api/addresses/0"><![CDATA[0]]></ID_ADDRESS_DELIVERY>
	<QUANTITY><![CDATA[2]]></QUANTITY>
	</CART_ROW>
	<CART_ROW>
	<ID_PRODUCT xlink:href="https://myshop.com/api/products/3"><![CDATA[3]]></ID_PRODUCT>
	<ID_PRODUCT_ATTRIBUTE xlink:href="https://myshop.com/api/combinations/0"><![CDATA[0]]></ID_PRODUCT_ATTRIBUTE>
	<ID_ADDRESS_DELIVERY xlink:href="https://myshop.com/api/addresses/0"><![CDATA[0]]></ID_ADDRESS_DELIVERY>
	<QUANTITY><![CDATA[1]]></QUANTITY>
	</CART_ROW>
	<CART_ROW>
	<ID_PRODUCT xlink:href="https://myshop.com/api/products/968"><![CDATA[968]]></ID_PRODUCT>
	<ID_PRODUCT_ATTRIBUTE xlink:href="https://myshop.com/api/combinations/0"><![CDATA[0]]></ID_PRODUCT_ATTRIBUTE>
	<ID_ADDRESS_DELIVERY xlink:href="https://myshop.com/api/addresses/0"><![CDATA[0]]></ID_ADDRESS_DELIVERY>
	<QUANTITY><![CDATA[3]]></QUANTITY>
	</CART_ROW>
	<CART_ROW>
	<ID_PRODUCT xlink:href="https://myshop.com/api/products/2949"><![CDATA[2949]]></ID_PRODUCT>
	<ID_PRODUCT_ATTRIBUTE xlink:href="https://myshop.com/api/combinations/0"><![CDATA[0]]></ID_PRODUCT_ATTRIBUTE>
	<ID_ADDRESS_DELIVERY xlink:href="https://myshop.com/api/addresses/0"><![CDATA[0]]></ID_ADDRESS_DELIVERY>
	<QUANTITY><![CDATA[7]]></QUANTITY>
	</CART_ROW>
	<CART_ROW>
	<ID_PRODUCT xlink:href="https://myshop.com/api/products/2978"><![CDATA[2978]]></ID_PRODUCT>
	<ID_PRODUCT_ATTRIBUTE xlink:href="https://myshop.com/api/combinations/0"><![CDATA[0]]></ID_PRODUCT_ATTRIBUTE>
	<ID_ADDRESS_DELIVERY xlink:href="https://myshop.com/api/addresses/0"><![CDATA[0]]></ID_ADDRESS_DELIVERY>
	<QUANTITY><![CDATA[15]]></QUANTITY>
	</CART_ROW>
</CART_ROWS>

But, CART_ROW is order by id_product.

How to get the same result order by date_add (the last product insert by customer on the end off cart_rows collection)

 

Thank you

Edited by Conselio (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...