<div class="container">
  <div class="row justify-content-md-center mt-5">
    <div class="col-6">
      <div class="card">
        <div class="card-body">
          <h5 class="card-title">Assigning values for product additional fields</h5>
          <p class="card-text">
            Click the button bellow to open the Inline Cart using a catalog product which has the additional fields values assigned.
          </p>
          <a href="#" class="btn btn-success" id="buy-button">Buy now!</a>
        </div>
      </div>
    </div>
  </div>
</div>
window.document.getElementById('buy-button').addEventListener('click', function() {
  TwoCoInlineCart.cart.setCurrency('USD');

  TwoCoInlineCart.products.add({
    code: '2CO3MONTHS',
    quantity: 1,
    additionalFields: [
      // textbox type example
      {
        code     : 'NewsletterPolicy12345768',
        value    : 'Some text value'
      },
      // listbox type example
      {
        code     : 'cart2cotestlist',
        value    : 'YES'
      },
      // hidden type example
      {
        code     : 'HiddenID123',
        value    : 'Some text for the hidden field'
      },
      // checkbox type example
      {
        code     : 'cart2cotest',
        value    : true
      }
    ],
  });
  
  TwoCoInlineCart.cart.checkout();
});

External CSS

  1. https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css

External JavaScript

  1. https://codepen.io/2checkout-documentation/pen/Ezreqy