Jump to content

Challenger2

Member
  • Posts

    37
  • Joined

  • Last visited

Posts posted by Challenger2

  1. On 3/25/2021 at 4:57 AM, creedon said:

    I have updated my previous code post.

    You will want to use the targetAtttributeValue setting as follows to open into a new window.

    
    const targetAtttributeValue = '_blank';

    Let us know how it goes.

    And I have one other (possibly different) question.  Is it possible for a product item (on a product page) to link to another page.  So, rather than the item opening the product item page, it goes to another page?  I have a number of product pages, and want to link an apparent product item to another product page.

  2. On 10/30/2020 at 11:03 PM, creedon said:

    To redirect to a scheduling page upon clicking the Reserve Your Date button add the following to Store Settings > Advanced > Page Header Code Injection.

    
    <script>
    
      $( ( ) => {
      
        // replace add to cart button on product item with button that goes to a url
        
        const skuUrlMappings = {
        
          /*
          
            skus can be copied from a product item
            
            if you need more than one mapping then copy and repeat the line below
            for each mapping, remove the "// " at the beginning of the line and
            enter the appropriate data
            
            the url can be any valid url in the context of Squarespace. It can be
            a full one like "https://www.squarespace.com/" or a partial url like
            "/contact"
            
            */
            
          // '[enter sku here]' : '[enter url here]',
          
          // last or only item doesn't get a comma at the end
          
          'SQ2015221' : 'https://www.squarespace.com/'
          
          }
          
        /*
        
          used when a mapping is not defined for a product that has other mappings
          defined
          
          */
          
        defaultUrl = 'https://squarespace.com/';
        
        // do not change anything below, there be the borg here
        
        if ( ! $( '.ProductItem' ).length ) return;
        
        const skus = $.map ( Static.SQUARESPACE_CONTEXT.product.variants,
        
          function ( v ) {
          
            return ( v.sku );
            
            } );
            
        /*
        
          if our skus don't contain a mapped sku then bail, in other words does not
          replace add to cart button
          
          */
          
        if ( ! skus.some ( r => Object.keys ( skuUrlMappings ).indexOf ( r ) >= 0 )
        
          ) return;
          
        let $addToCartButton = $( '.sqs-add-to-cart-button' );
        
        let $addToCartButtonClone = $addToCartButton.clone ( )
        
          .click ( function ( ) {
          
            let sku = skus [ 0 ]; // we assume one variant for product item
            
            // we go looking for more than one
            
            let $productVariants = $( '.product-variants' );
            
            if ( $productVariants.length ) {
            
              let selectedVariant = $( '.product-variants' )
              
                .attr ( 'data-selected-variant' );
                
              if ( selectedVariant === undefined ) return;
              
              selectedVariant = JSON.parse ( selectedVariant );
              
              sku = selectedVariant.sku;
              
              }
              
            const url = sku in skuUrlMappings ? skuUrlMappings [ sku ] : defaultUrl;
            
            location = url;
            
            } );
            
        $addToCartButton.replaceWith ( $addToCartButtonClone );
        
        } );
        
      </script>

    Let us know how it goes.

    Hi @creedon, this is brilliant thank you!  Is there any way to make it open in a new window...?

  3. Hi Zoe and Paul,

    In the v7.0 Brine family, I have managed to style the checkout button using the following code:

    body .checkout button.CheckoutButton-checkoutButton-3yWY2 {
       display:block;
      font-size: 13px;
      text-transform: uppercase;
      letter-spacing: 2px;
      color:#231f74;
      font-weight: 700;
      font-style: normal;
      line-height: normal;
      opacity:1;
      text-align: center;
      width: auto;
      height: auto;
      text-decoration: none;
      padding: 9px 20px;
      background-color: white;
      border-radius: 3px;
      transition: .1s opacity linear;
      cursor: pointer;
      border-color: #231f74;
      border-width:2px;
      border-style:solid;
      margin-top:10px;
    }
    body .checkout button.CheckoutButton-checkoutButton-3yWY2:hover {color: #fff; background-color: #231f74;}

    I'm using it at https://skywavegin.com

  4. Hi again @Hickory,

    Markdown uses standard HTML, so to add an extra space, use

    &nbsp

    as in the following example:

    
    
         <body>
           Your`&nbsp`text`&nbsp`here
        </body>
    
    

    Don't use the quote marks, and put a ';' after each (I couldn't get this system to just let me type that!) You can put as many in sequence as you like, each adds a 'non (line) breaking space'.

    Centreing is just as easy. Use the style "text-align: center" as follows in any tag (note US spelling of 'center'):

    
    
    <div style="text-align:center">This text will be centred.
    <p>So will this paragraph.</p></div>
    
    

    Or

    
    
    <p style="text-align:center">This line will be centred.<br>
    And so will this line.</p>
    
    

    Let me know how you get on.

  5. Hi @Hickory.

    Use a markdown, not a text box. In the markdown use code like this:

    
    
    <div class="boxBorder">
    Your text here...
    </div>
    
    

    Then in the custom css use the following code, adjusting the values for size and colour as you wish:

    
    
    .boxBorder {
         border: 2px solid #990066;
         padding: 10px;
         outline: #990066 solid 5px;
         outline-offset: 5px;
       }
    
    

    Hope this works for you.

×
×
  • 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.