Support the ongoing development of →
Blade JavaScript Laravel

Hello @patelmahmed

Can you explain more in what you need and what you have tried?


i want to add gst tex in laravel e-commerce website...3 type gst in product gst add in laravel 8


Calculate GST Tax in Amount in laravel e-commerce website...explain step by step brief


To add SGST, CGST, and IGST calculations to your e-commerce website's cart and checkout pages using JavaScript, you can follow these steps:

Create a function to determine the type of tax (CGST + SGST or IGST) based on the buyer's and seller's GSTIN:

function determineTaxType(buyerGstin, sellerGstin) {
  return buyerGstin.substring(0, 2) === sellerGstin.substring(0, 2) ? 'intraState' : 'interState';
Create a function to calculate the tax amounts based on the tax type and tax rates:
function calculateTaxes(taxType, taxRates, taxableAmount) {
  const taxes = { cgst: 0, sgst: 0, igst: 0 };

  if (taxType === 'intraState') {
    taxes.cgst = taxableAmount * taxRates.cgst / 100;
    taxes.sgst = taxableAmount * taxRates.sgst / 100;
  } else {
    taxes.igst = taxableAmount * taxRates.igst / 100;

  return taxes;

Define the tax rates for your products:

const taxRates = {
  product1: { cgst: 9, sgst: 9, igst: 18 },
  product2: { cgst: 14, sgst: 14, igst: 28 },
  // Add more products and their tax rates

Use the above functions to calculate the taxes for each item in the cart:

const cartItems = [
  { id: 'product1', price: 100, quantity: 2 },
  { id: 'product2', price: 200, quantity: 1 },
  // Add more items

const buyerGstin = '27XXXXXXX1234Z5';
const sellerGstin = '29XXXXXXX1234Z5';

const taxType = determineTaxType(buyerGstin, sellerGstin);

cartItems.forEach((item) => {
  const taxableAmount = item.price * item.quantity;
  const taxes = calculateTaxes(taxType, taxRates[], taxableAmount);

  item.cgst = taxes.cgst;
  item.sgst = taxes.sgst;
  item.igst = taxes.igst;

Display the calculated taxes on the cart and checkout pages, and include them in the total amount.

<!-- Cart table -->
  <!-- Table header -->
  <!-- Cart items -->
  <tr v-for="item in cartItems">
    <td>{{ }}</td>
    <td>{{ item.price }}</td>
    <td>{{ item.quantity }}</td>
    <td>{{ item.cgst.toFixed(2) }}</td>
    <td>{{ item.sgst.toFixed(2) }}</td>
    <td>{{ item.igst.toFixed(2) }}</td>
    <td>{{ (item.price * item.quantity + item.cgst + item.sgst + item.igst).toFixed(2) }}</td>

By following these steps, you can add SGST, CGST, and IGST calculations in your e-commerce website's cart and checkout pages using JavaScript. Adjust the tax rates and GSTINs according to your specific use case and product catalog.


Thanks for the steps. You made my day. I also would like to help you by sharing the website with you where you online casinos sites through which you can make money. I am also using that platform to find online real money gaming sites.

Last updated 1 year ago.

bencullendev liked this reply


Sign in to participate in this thread!


Your banner here too?

muhammed patelmahmed Joined 2 Feb 2023


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.