Choose between using Paypal or Google Checkout for your shopping cart - unfortunately, both options cannot be used

My dilemma is that I currently have a functional shopping cart that is only coded for either Paypal or Google Checkout, not both.

Here is a demo of the shopping cart set up for Paypal checkout:

The javascript code used in the demo can be found here:

Looking at the javascript code, you can see that it provides options for Paypal OR Google checkout, shown as:

var NextId=1,Custom="Custom",GoogleCheckout="GoogleCheckout",PayPal="PayPal",Email="Email", 

By selecting the appropriate option within the "/head" section, you can choose your preferred checkout method:

<script src='http://shopppingcart.googlecode.com/files/simplecart.js' type='text/javascript'></script>
<script type='text/javascript'>
simpleCart.email = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4c29342d213c20290c2b212d2520622f2321">[email protected]</a>";
simpleCart.checkoutTo = PayPal;
simpleCart.currency = USD;

simpleCart.cartHeaders = ["thumb_image" , "Quantity_input" ,   "Total", "remove" ]; 
</script>

However, the issue arises when trying to enable both checkout options simultaneously. Currently, there is only one checkout button that leads to the javascript code:

<a class='simpleCart_checkout' href='javascript:;'>Checkout</a>

Any suggestions or ideas on how to configure the shopping cart to accept BOTH Paypal and Google Checkout would be greatly appreciated.

P.S. My expertise lies in HTML, CSS, and jQuery, with limited knowledge in javascript.

Answer №1

Referenced from: SimpleCart-JS GitHub Page

uncomment all instances of <strong>checkoutTo</strong>:

// simpleCart.checkoutTo = GoogleCheckout;

and insert the following functions: I devised a simple method:

function usePaypal(){ simpleCart.checkoutTo = PayPal; } function useGoogle(){ simpleCart.checkoutTo = GoogleCheckout; }

Next, here are my checkout choices:

<a href="javascript:;" class="simpleCart_checkout" onclick="usePaypal();" >checkoutpaypal</a>

<a href="javascript:;" class="simpleCart_checkout" onclick="useGoogle();" >checkoutgoogle</a>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Securing uploaded documents and limiting access to approved individuals

Currently, I am utilizing Multer for file uploads and I am contemplating the ideal approach to secure access to these files post-upload. In my system, there are two user roles: admin and regular user. Users can only upload photos while only admins have ac ...

Choose every fourth row in the table

Is there a way to alternate the background colors of selected groups of 4 rows in a table? I want to make one group red and the next group blue. Any suggestions or ideas on how to achieve this? <table> <tr style="background-color: red;"> ...

What is the best way to extract multiple variables from a function in JavaScript?

After creating the function buttonEffects() with four different button effects, I am now facing the challenge of bringing these variables outside of the function and using them in another function. Is it possible to achieve this without recoding everything ...

The inclusion of HttpClient is causing issues with the functionality of my component

Currently, I am facing an issue with my Angular service called ConnexionService. The problem arises when I try to incorporate CSV files into this service using HttpClient. Strangely, the component associated with this service fails to display once HttpClie ...

In Ruby on Rails, ensure to trigger the ajax:beforeSend and ajax:complete events when using the link_to method with the remote

I'm currently developing a web app using Ruby on Rails as the framework. We have been utilizing the link_to method with remote true for all partial renders, following instructions provided in this helpful resource. However, I am looking to associate t ...

An empty array is being returned from a mongoose function call

I'm currently working on a project that involves fetching random values from MongoDB using mongoose and storing them in an array. However, I am facing an issue where the array appears to be empty outside the function: exports.Run = (req, res) => { ...

Tips for successfully accessing a variable in an Angular Pipe

When displaying output, I need to show a specific number of decimal digits based on the length returned by a stored procedure. The length of these decimal digits can vary, and I only need to focus on the decimal part, not the integer part. To achieve this, ...

Tool designed to analyze the timing of sub requests and methods in Node for benchmarking purposes

For my benchmarking and load testing needs, I initially utilized tools such as Apache Bench, Siege, and benchmark.js. However, these tools only provided me with the overall result or time taken from start to finish of the test. I am now seeking a tool or l ...

Implement ES6 classes for managing state in the vuex store within a Nuxt application

After setting an ES6 class to the state in my vuex store in nuxt, I encountered the following warning: WARN Cannot stringify arbitrary non-POJOs EndPoint However, when I use an object as the state, it works without any warnings. So the question arises ...

Sending files in Express causes issues

I keep receiving the following message: express deprecated res.sendfile: Use res.sendFile instead Here is the code snippet in question: app.get('/*', function (req, res) { var myUrl = req.url.split('/')[1]; myownfunction(myUrl ...

What could be causing my browser to display twice the height value?

After running the code below on my browser, I noticed that the height value is rendered double. To start off, I tested the following code in about:blank. In the HTML: ... <canvas id="canvasArea" style=" width: 500px; height: ...

Personalize the marker design within the Wikitude SDK using JavaScript

Currently, I am developing an augmented reality view in Android using the wikitude-sdk. As part of the project, I am displaying markers on the screen and now I am looking to customize the marker view using the AR.HtmlDrawable method offered by the ...

Ensure to verify the presence of a specific element in an array prior to examining the rest in Javascript

I am currently working with an array of objects and I need to check if any of the objects have a title of 'food' before checking for any other titles. However, my current code checks sequentially. Below you will find the code snippet: let db = ...

Retrieving information from the API to populate a child component in Next.js

I have been developing a header component and here's the code snippet: import style from '../../styles/header.css'; import '../../styles/globals.css'; export default function Header({data}){ const [showMe, setShowMe] = useStat ...

Are Lazily Instantiated Singletons a Thing in AngularJS?

After browsing through the AngularJS documentation, I came across an interesting detail about AngularJS services: AngularJS lazily instantiates services, meaning they are only created when a component in the application requires it. Services in AngularJ ...

What could be the reason for the variable not resetting in my event handler?

Check out the code I've written below: $(document).ready(function () { var default_var = 2; var show_var = default_var; var total_var = 8; var increment_var = 2; var start_var = show_var+1; var end_var = show_var+increment_v ...

Updating an Object in vue.js Upon Click Event to Add a New Value

I currently have a code snippet that looks like the following: arr = [ { val1: a, val2: b }, { val1: a, val2: b }, { val1: a, val2: b } ] <div v-for="single in arr"> <button v-on:click="addSome"></button> </div> When I c ...

What is the best way to incorporate Bootstrap 5 into a content script without causing any conflicts with the existing CSS of the website? (Chrome Extension)

In the process of integrating the Bootstrap 5 library into a Chrome extension, I have encountered an issue where the CSS and JS files conflict with the main CSS file on certain websites. To address this, I have included the Bootstrap 5 (CSS and JS) files i ...

Eliminate HTML field based on checkbox status

I'm looking to dynamically remove HTML fields based on a Yes/No condition. I've shared the code below for better understanding. If Yes is selected, I want to hide the No Field/Input/Box and vice versa. function AutoCheck() { if (document.getEl ...

Unable to navigate beyond the boundaries of an app

I am currently facing an issue with my authentication service where it redirects to the identity server in case of certain errors. I attempted to achieve this using window.location.href = environment.authCodeFlowIssuer;, however, an error occurred: Ref ...