Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Solution to add PayPal to the list of credit card types on a storefront checkout *and* hide credit card info when PayPal is clicked.
<!-- SalsaStaff: Add PayPal to the list of credit card types on a storefront checkout.
See -->
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
if (RegExp('shop/checkOut.jsp\\?storefront_KEY=').test(window.location.href)) {
// Script to append PayPal to credit card types in storefronts.
var e = document.querySelector('#cardtypes input[value="paypal"]');
if (e === null) {
e = document.querySelector('#cardtypes');
// Script to hide credit card information if Paypal is selected.
// Also shows credit card info if another credit card type is selected.
Array.from(document.querySelectorAll('#cardtypes input'))
.forEach(function(e) {
e.addEventListener('click', function(event) {
var mode = == 'paypal' ? 'none' : 'block';
document.querySelector('#cardInfo > table').style.display = mode;
<div style="display: none;">
<li id="added-paypal">
<input type="radio" class="radio" name="cc_type" value="paypal">
<span class="dia_field_name">PayPal</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.