Jump to content

Retrieve current cart info


Recommended Posts

 

Hi !

I'm on P.S 1.6.1.18

I am creating a payment module and I'm stuck.

 I need to send those informations to an API:

  • orderId
  • quantity
  • currency 
  • itemDescription
  • itemRef

I'm using this code for retrieving current cart info 

 $this->context->smarty->assign(array(

            'cart' => $cart,

            'cart_details' => $cart_details,

        ));

OUTPUT

 array (size=23) 'delivery' => object(Address)[840] public 'id_customer' => string '140' (length=3) public 'id_manufacturer' => string '0' (length=1) public 'id_supplier' => string '0' (length=1) public 'id_warehouse' => string '0' (length=1) public 'id_country' => string '3' (length=1) public 'id_state' => string '0' (length=1) public 'country' => string 'Belgique' (length=8) public 'alias' => string 'Maison' (length=6) public 'company' => null public 'lastname' => string '' (length=2) public 'firstname' => string '' (length=7) public 'address1' => string ' (length=19) public 'address2' => null public 'postcode' => string '' (length=4) public 'city' => string '' (length=10) public 'other' => null public 'phone' => string '' (length=9) public 'phone_mobile' => string '' (length=10) public 'vat_number' => null public 'dni' => null public 'date_add' => string '2018-08-25 10:45:51' (length=19) public 'date_upd' => string '2018-08-25 10:45:51' (length=19) public 'deleted' => string '0' (length=1) protected '_includeVars' => array (size=1) 'addressType' => string 'table' (length=5) protected '_includeContainer' => boolean false protected 'webserviceParameters' => array (size=2) 'objectsNodeName' => string 'addresses' (length=9) 'fields' => array (size=6) ... public 'id' => int 32 protected 'id_lang' => null protected 'id_shop' => null public 'id_shop_list' => null protected 'get_shop_from_context' => boolean true protected 'table' => string 'address' (length=7) protected 'identifier' => string 'id_address' (length=10) protected 'fieldsRequired' => array (size=6) 0 => string 'id_country' (length=10) 1 => string 'alias' (length=5) 2 => string 'lastname' (length=8) 3 => string 'firstname' (length=9) 4 => string 'address1' (length=8) 5 => string 'city' (length=4) protected 'fieldsSize' => array (size=12) 'alias' => int 32 'company' => int 255 'lastname' => int 32 'firstname' => int 32 'address1' => int 128 'address2' => int 128 'postcode' => int 12 'city' => int 64 'other' => int 300 'phone' => int 32 'phone_mobile' => int 32 'dni' => int 16 protected 'fieldsValidate' => array (size=22) 'id_customer' => string 'isNullOrUnsignedId' (length=18) 'id_manufacturer' => string 'isNullOrUnsignedId' (length=18) 'id_supplier' => string 'isNullOrUnsignedId' (length=18) 'id_warehouse' => string 'isNullOrUnsignedId' (length=18) 'id_country' => string 'isUnsignedId' (length=12) 'id_state' => string 'isNullOrUnsignedId' (length=18) 'alias' => string 'isGenericName' (length=13) 'company' => string 'isGenericName' (length=13) 'lastname' => string 'isName' (length=6) 'firstname' => string 'isName' (length=6) 'vat_number' => string 'isGenericName' (length=13) 'address1' => string 'isAddress' (length=9) 'address2' => string 'isAddress' (length=9) 'postcode' => string 'isPostCode' (length=10) 'city' => string 'isCityName' (length=10) 'other' => string 'isMessage' (length=9) 'phone' => string 'isPhoneNumber' (length=13) 'phone_mobile' => string 'isPhoneNumber' (length=13) 'dni' => string 'isDniLite' (length=9) 'deleted' => string 'isBool' (length=6) 'date_add' => string 'isDate' (length=6) 'date_upd' => string 'isDate' (length=6) protected 'fieldsRequiredLang' => array (size=0) empty protected 'fieldsSizeLang' => array (size=0) empty protected 'fieldsValidateLang' => array (size=0) empty protected 'tables' => array (size=0) empty protected 'image_dir' => null protected 'image_format' => string 'jpg' (length=3) protected 'def' => array (size=4) 'table' => string 'address' (length=7) 'primary' => string 'id_address' (length=10) 'fields' => array (size=22) ... 'classname' => string 'Address' (length=7) protected 'update_fields' => null public 'force_id' => boolean false 'delivery_state' => boolean false 'invoice' => object(Address)[855] public 'id_customer' => string '140' (length=3) public 'id_manufacturer' => string '0' (length=1) public 'id_supplier' => string '0' (length=1) public 'id_warehouse' => string '0' (length=1) public 'id_country' => string '3' (length=1) public 'id_state' => string '0' (length=1) public 'country' => string 'Belgique' (length=8) public 'alias' => string 'Maison' (length=6) public 'company' => null public 'lastname' => string '' (length=2) public 'firstname' => string '' (length=7) public 'address1' => string '' (length=19) public 'address2' => null public 'postcode' => string '' (length=4) public 'city' => string '' (length=10) public 'other' => null public 'phone' => string '' (length=9) public 'phone_mobile' => string '' (length=10) public 'vat_number' => null public 'dni' => null public 'date_add' => string '2018-08-25 10:45:51' (length=19) public 'date_upd' => string '2018-08-25 10:45:51' (length=19) public 'deleted' => string '0' (length=1) protected '_includeVars' => array (size=1) 'addressType' => string 'table' (length=5) protected '_includeContainer' => boolean false protected 'webserviceParameters' => array (size=2) 'objectsNodeName' => string 'addresses' (length=9) 'fields' => array (size=6) ... public 'id' => int 32 protected 'id_lang' => null protected 'id_shop' => null public 'id_shop_list' => null protected 'get_shop_from_context' => boolean true protected 'table' => string 'address' (length=7) protected 'identifier' => string 'id_address' (length=10) protected 'fieldsRequired' => array (size=6) 0 => string 'id_country' (length=10) 1 => string 'alias' (length=5) 2 => string 'lastname' (length=8) 3 => string 'firstname' (length=9) 4 => string 'address1' (length=8) 5 => string 'city' (length=4) protected 'fieldsSize' => array (size=12) 'alias' => int 32 'company' => int 255 'lastname' => int 32 'firstname' => int 32 'address1' => int 128 'address2' => int 128 'postcode' => int 12 'city' => int 64 'other' => int 300 'phone' => int 32 'phone_mobile' => int 32 'dni' => int 16 protected 'fieldsValidate' => array (size=22) 'id_customer' => string 'isNullOrUnsignedId' (length=18) 'id_manufacturer' => string 'isNullOrUnsignedId' (length=18) 'id_supplier' => string 'isNullOrUnsignedId' (length=18) 'id_warehouse' => string 'isNullOrUnsignedId' (length=18) 'id_country' => string 'isUnsignedId' (length=12) 'id_state' => string 'isNullOrUnsignedId' (length=18) 'alias' => string 'isGenericName' (length=13) 'company' => string 'isGenericName' (length=13) 'lastname' => string 'isName' (length=6) 'firstname' => string 'isName' (length=6) 'vat_number' => string 'isGenericName' (length=13) 'address1' => string 'isAddress' (length=9) 'address2' => string 'isAddress' (length=9) 'postcode' => string 'isPostCode' (length=10) 'city' => string 'isCityName' (length=10) 'other' => string 'isMessage' (length=9) 'phone' => string 'isPhoneNumber' (length=13) 'phone_mobile' => string 'isPhoneNumber' (length=13) 'dni' => string 'isDniLite' (length=9) 'deleted' => string 'isBool' (length=6) 'date_add' => string 'isDate' (length=6) 'date_upd' => string 'isDate' (length=6) protected 'fieldsRequiredLang' => array (size=0) empty protected 'fieldsSizeLang' => array (size=0) empty protected 'fieldsValidateLang' => array (size=0) empty protected 'tables' => array (size=0) empty protected 'image_dir' => null protected 'image_format' => string 'jpg' (length=3) protected 'def' => array (size=4) 'table' => string 'address' (length=7) 'primary' => string 'id_address' (length=10) 'fields' => array (size=22) ... 'classname' => string 'Address' (length=7) protected 'update_fields' => null public 'force_id' => boolean false 'invoice_state' => boolean false 'formattedAddresses' => array (size=2) 'delivery' => array (size=3) 'ordered' => array (size=9) ... 'formated' => array (size=11) ... 'object' => array (size=20) ... 'invoice' => array (size=3) 'ordered' => array (size=9) ... 'formated' => array (size=11) ... 'object' => array (size=20) ... 'products' => array (size=2) 0 => array (size=65) 'id_product_attribute' => string '1319' (length=4) 'id_product' => string '2025' (length=4) 'cart_quantity' => string '1' (length=1) 'id_shop' => string '1' (length=1) 'name' => string 'Samsung Galaxy S21' (length=18) 'is_virtual' => string '0' (length=1) 'description_short' => string '' (length=0) 'available_now' => null 'available_later' => null 'id_category_default' => string '2' (length=1) 'id_supplier' => string '3' (length=1) 'id_manufacturer' => string '0' (length=1) 'on_sale' => string '0' (length=1) 'ecotax' => string '0.000000' (length=8) 'additional_shipping_cost' => string '0.00' (length=4) 'available_for_order' => string '1' (length=1) 'price' => float 699.96 'active' => string '1' (length=1) 'unity' => null 'unit_price_ratio' => string '0.000000' (length=8) 'quantity_available' => string '1' (length=1) 'width' => string '0.000000' (length=8) 'height' => string '0.000000' (length=8) 'depth' => string '0.000000' (length=8) 'out_of_stock' => string '2' (length=1) 'weight' => float 0 'date_add' => string '2021-10-01 15:20:48' (length=19) 'date_upd' => string '2021-12-15 13:36:04' (length=19) 'quantity' => int 1 'link_rewrite' => string 'samsung-galaxy-s21' (length=18) 'category' => string 'accueil' (length=7) 'unique_id' => string '0000002025000000131932' (length=22) 'id_address_delivery' => string '32' (length=2) 'advanced_stock_management' => string '0' (length=1) 'supplier_reference' => null 'customization_quantity' => null 'id_customization' => null 'price_attribute' => string '0.000000' (length=8) 'ecotax_attr' => string '0.000000' (length=8) 'reference' => string '4627' (length=4) 'weight_attribute' => string '0.000000' (length=8) 'ean13' => null 'upc' => null 'minimal_quantity' => string '1' (length=1) 'wholesale_price' => string '0.000000' (length=8) 'id_image' => string '2025-2860' (length=9) 'legend' => string 'Samsung Galaxy S21' (length=18) 'reduction_type' => int 0 'stock_quantity' => int 1 'price_without_reduction' => float 846.9516 'price_with_reduction' => float 846.9516 'price_with_reduction_without_tax' => float 699.96 'total' => float 699.96 'total_wt' => float 846.95 'price_wt' => float 846.9516 'reduction_applies' => boolean fal…

They give me all products one by one but  I would like to retrieve all names, quantity and reference  in one line.

I need something like this

{

  "orderId": "2021/350",

  "customerRef": "DEVO/TST/22",

  "orderLines": [

    {

      "itemRef": "PL-MF-7745",

      "itemDescription": "CHAISES CANTILEVER MODERNES",

      "quantity": 4

    }

  ],

  "orderTotalAmount": "1576.86",

  "currency": "EUR",

  "callbackSuccessUrl": "http://www.dhnet.be",

"callbackFailureUrl": "http://www.rtbf.be"

 

}

Could someone help me please? 

 Thanks in advance for your answers.

Falcaol

 

Sorry for my bad english

Link to comment
Share on other sites

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...