Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Express checkout for certain products only


creedon
Go to solution Solved by creedon,

Question

  • Answers 4
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Popular Posts

@Carrzer You can skip the following step as you already have jQuery installed. Add the following to Settings > Advanced > Code Injection > HEADER. <script src="https://ajax.g

Creedon you are a genius 🙂 This seems to be working perfectly. Thank you, thank you , thank you! 

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

@Carrzer

You can skip the following step as you already have jQuery installed.

Add the following to Settings > Advanced > Code Injection > HEADER.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Add the following to Store Settings > Advanced > Page Header Code Injection for the store page where you want "Express Checkout".

<script>

  $( ( ) => {
  
    /*
    
      redirect to url after add to cart button has been clicked and SS indicates
      item has been added to cart
      
      SS Versions : 7.0, 7.1
      
      Note        : has auto click feature, meaning the add to cart button will
                    automatically be clicked when the page is loaded
                    
      */
      
    const url = '/checkout';
    
    const autoClick = false;
    
    // do not change anything below, there be the borg here
    
    if ( ! $( '.ProductItem' ).length ) return; // bail if not product detail
    
    if ( ! 'MutationObserver' in window ) return;
    
    const observer = new MutationObserver ( function ( mutations ) {
    
      $.each ( mutations, function ( ) {
      
        if ( ! this.attributeName.length ) return;
        
        if ( this.attributeName != 'class' ) return;
        
        const $e = $( this.target );
        
        if ( ! $e.hasClass ( 'cart-added' ) ) return;
        
        location.href = url;
        
        } );
        
      } );
      
    const $addToCartButton = $( '.sqs-add-to-cart-button-wrapper:first' );
    
    // start listening for changes in element with class sqs-add-to-cart-button
    
    observer.observe ( $( '.sqs-add-to-cart-button', $addToCartButton ) [ 0 ], {
    
      attributes : true
      
      } );
      
    // auto click add to cart button
    
    if ( autoClick )
    
      $( '.sqs-add-to-cart-button-inner', $addToCartButton ).click ( );
      
    } );
    
  </script>

This is for v7.0 and v7.1.

Let us know how it goes.

Edited by creedon

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

Link to post
  • 0
8 hours ago, Carrzer said:

Is this possible? 

@Carrzer

I believe it is.

Please post the URL for the store on your site.

If your site is not public please set up a site-wide password, if you've not already done so.

Post the password here.

Adding a site-wide password is not a security breach. Please read the documentation at the link provided to understand how it works.

We can then take a look at your issue.

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

Link to post
  • 0

Hi Creedon, thanks for getting back to me 🙂 

The URL for the store I am wanting this feature for is: https://www.inspa.ie/print-positive-portraits (It's a work in progress but all products in this store to have Express Checkout feature). 

You will notice on my website I have another main store called 'Print Lab' which I do not want Express Checkout for etc.

You may also notice I put some custom CSS in to have a Go to Cart button appear under the Add to Cart button. I am only testing this so this can be removed if needed.

Hoping this helps

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...