1.8.0 ā€¢ Published 12 months ago

@rallycommerce/checkout-button v1.8.0

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

Rally ā™„ Next.js

To successfully integrate the Rally Checkout Button follow the steps below.

1. Install the Rally Checkout Button

npm install @rallycommerce/checkout-button

2. Create a Rally Checkout Button component

Create a RallyCheckoutButton.tsx component in the project with the following content šŸ‘‡. Structure example šŸ‘‰ lib/rally/RallyCheckoutButton.tsx

import React from 'react'
import { Rally, RallyCheckoutButtonConfig } from '@rallycommerce/checkout-button';

declare global {
  namespace JSX {
    interface IntrinsicElements {
      'rally-checkout-button': any;
    }
  }
}
interface RallyCheckoutButtonProps {
  customText?: string | undefined;
  customClass?: string | undefined;
  cart?: any;
}

const RallyCheckoutButton = (props: RallyCheckoutButtonProps) => {
  const customClass = props.customClass || "rally-custom-button-class";
  const cart = props?.cart;

  if (cart) {
    const configuration: RallyCheckoutButtonConfig = {
      cartData: { content: cart, id: cart.id, currency: cart.currency }
    };

    Rally.init('clientId', configuration);
  }

  return (<>
    {<rally-checkout-button suppressHydrationWarning={true} custom-class={customClass} custom-text={props.customText} loader="true">
    </rally-checkout-button>}
  </>)
}

export default RallyCheckoutButton;

3. Import the Rally Checkout Button component

The component can now be imported (ex. on the cart page) like this šŸ‘‡.

import dynamic from 'next/dynamic';
const RallyCheckoutButton = dynamic(() => import('@lib/rally/RallyCheckoutButton'), {
  ssr: false,
})

import { Context } from '../../lib/xy/storefront-data-hooks/src/Context'; 
const { cart } = useContext(Context)


 <RallyCheckoutButton cart={cart} customText="Custom text" customClass="custom-css-class"></RallyCheckoutButton>

To learn more about Rally's Checkout Button capabilities visit our Developer's portal.

1.8.0

12 months ago

1.7.0

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.1

2 years ago

1.3.6

2 years ago

1.4.0

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

1.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago