Knowledgebase
How do I add the Pay with Amazon code block to my customized "view_cart.html" template?

If you would like to use Pay with Amazon, and have previously made customizations to your store's view_cart.html template, you will need to consider the following two options in order to have the Pay with Amazon function appear on your checkout page.

Option 1: Favor the global file from the common folder.

The easiest method to use will be to remove your customized template file and just favor the file that comes from the folder. To do this, simply FTP to your store's FTP access and navigate to web/assets/template/[them_folder] (where [theme_folder] is your store's chosen theme.

Once there, simply rename or delete the existing view_cart.html file

The store will then favor the global view_cart.html file that is served from the common folder.


Option 2: Add the necessary coding to your customized template file.

On the other hand, if you do not wish to lose whatever customizations you may have on the view cart page, then the second option would be to manually add the necessary coding to the page yourself.

To do this:

  1. Go to Settings >Design >Themes & Styles
  2. At the top right of the page, click on the "More" button and select "Edit Template (HTML)"
  3. Locate your custom "view_cart.html" file and click on its Action Wheel to select "edit"
  4. Add the following code to the template between the existing <!--END: checkoutByAmazon--> and <!--START: shopatron--> tags
    <!--START: PayWithAmazon-->

    <script type='text/javascript'>
window.onAmazonLoginReady = function () {
amazon.Login.setClientId('[amazonpay_clientid]');
};
</script>
<script type='text/javascript' src='https://static-na.payments-amazon.com/OffAmazonPayments/us/[amazonpay_sandbox]js/Widgets.js'></script> <!-- Place this where you would like the Payment Button to appear -->
<div id="AmazonPayButton"></div>
<script type="text/javascript">
var authRequest;
var amazonOrderReferenceId;
OffAmazonPayments.Button("AmazonPayButton", "[amazonpay_sellerid]", {
type: "PwA",
color: "Gold",
size: "small",
authorization: function () {
var loginOptions = { scope: 'profile payments:widget payments:shipping_address', popup: true };
authRequest = amazon.Login.authorize(loginOptions, "[amazonpay_domain]/checkout_one.asp?wid=3");
},
onError: function (error) {
alert(error.getErrorMessage());
console.log(error);
}
});
</script>
<!--END: PayWithAmazon-->

Please Note
The information in this article is provided solely as a courtesy and to offer basic instructions on making very simple changes to your store's HTML templates.

Please understand that - regardless of how simple the changes may be - HTML changes and troubleshooting fall outside the scope of our support department. The 3dcart support team is neither trained, qualified, nor allowed to make these changes for you. The boundary of our scope in this matter is limited to providing these instructions and helping you reset the template if the changes don’t work as you wanted.

If you are uncomfortable with making changes to your site’s HTML, please contact your sales representative and inquire about our HTML and design services which can make these changes for you.

Thank you for your understanding


Help Desk Software by Kayako fusion