HOW to pass the items array while creating an order in javascript while using php

samebenezer
Contributor
Contributor

I have a shopping cart that can contain variable number of products based on the customer's preference.

I would line to know how to create and pass an array containing all the items in php to the javascript code before order creation.

Any help regarding this would be really helpful.

 

 

 

      createOrder: function(data, actions) {
      return actions.order.create({
        intent:"CAPTURE",
        application_context:{
          shipping_preference: 'SET_PROVIDED_ADDRESS',
          return_url :"",
        },
        purchase_units: [{
          amount: {
            currency_code: "USD",
            value: "<?php echo $total ?>"
          },
          items: {  //THIS IS WHERE I WANT TO INCLUDE EACH ITEM USING PHP 
          }
        }]
      });
    }

 

 

 

Login to Me Too
1 REPLY 1

MTS_Chiranjeevi
Moderator
Moderator

Hi @samebenezer,

 

Thank you for contacting PayPal community.

 

We apologize for any inconvenience.

 

I request to please use the "items" array  under "purchase_unit_request ".

 

Thank you for understanding and patience.

 

Sincerely,

Chiranjeevi

PayPal, Inc. 

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.