Jump to content

CCE

Member
  • Posts

    5
  • Joined

  • Last visited

Posts posted by CCE

  1. 14 minutes ago, creedon said:

    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.

    
    <script>
    
      $( ( ) => {
      
        /*
        
          add button after add to cart button of product detail page
          
          SS Versions : 7.0, 7.1
          
          */
          
        const text = 'View Shopping Bag';
        
        const url = '/cart';
        
        const targetAtttributeValue = ''; /* use _self (default, if left empty) |
                                             _blank | _parent | _top | framename */
        
        // do not change anything below, there be the borg here
        
        const $addToCartButton = $( '.sqs-add-to-cart-button-wrapper' );
        
        if ( ! $addToCartButton.length ) return;
        
        const buttonSelector = '.sqs-add-to-cart-button';
        
        let $additionalCartButton = $addToCartButton
        
          .clone ( )
          
          .removeAttr ( 'id' );
          
        let $e = $( buttonSelector, $additionalCartButton )
        
          .attr ( 'href', url )
          
          .removeAttr ( 'id ' +
          
            'data-collection-id ' +
            
            'data-item-id ' +
            
            'data-original-label ' +
            
            'data-product-type ' +
            
            'data-use-custom-label' )
            
          .find ( '.sqs-add-to-cart-button-inner' )
          
            .html ( text )
            
            .end ( );
            
        if ( targetAtttributeValue )
        
          $e.attr ( 'target', targetAtttributeValue );
          
        let $anchorTag = $( '<a>' );
        
        $.each ( $e.prop ( 'attributes' ), function ( ) {
        
          $anchorTag.attr ( this.name, this.value );
          
          } );
          
        $e
        
          .children ( )
          
          .appendTo ( $anchorTag );
          
        $e.replaceWith ( $anchorTag )
        
        $additionalCartButton.insertAfter ( $addToCartButton );
        
        } );
        
      </script>

    This is for v7.0 and v7.1.

    Let us know how it goes.

    I put it in, it works great but it only works when I remove the code I put in to hide the add to cart and quantity options. Once I put my code back in, it also removes the new button. 

     

    .product-quantity-input {
     display:none !important;
    }

    .sqs-add-to-cart-button-wrapper, {
     display:none !important;
    }

     

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.