Select Page

Setting Up a T-Shirt Store with drupal/commerce:^3.0

Drupal Commerce 3.x is optimized for Drupal 10 and introduces improvements in order processing, checkout flows, and tax/shipping handling. Below are the steps to set up your T-shirt store with automatic shipping and state tax calculations.

 

1. Install Drupal & Drupal Commerce

Run the following commands in your terminal to install Drupal and Drupal Commerce 3.x:

composer create-project drupal/recommended-project my_store cd my_store composer require drupal/commerce:^3.0

Enable required modules:

drush en commerce commerce_cart commerce_checkout commerce_store commerce_price commerce_product commerce_order commerce_tax commerce_shipping address -y drush updb

 

 

2. Configure the Store

Go to Commerce → Configuration → Store Settings → Stores and create a store with these settings:

  • Name: Your T-shirt Store
  • Address: 2000 S Mill Ave, Tempe, AZ 85282
  • Currency: USD
  • Default Country: United States

 

 

3. Add Products

Using Drupal Commerce 3 how to Create Product Variation Type (Size Attribute) for a “T-Shirt” product. Add an attribute called Size: Options: SM, MD, LG, XL, 2XL, 3XL

In Drupal Commerce 3.x, you can create a Product Variation Type with a Size attribute for your “T-Shirt” product using the following steps:

3.1 Create a Product Variation Type

  1. Go to Commerce → Configuration → Product Variation Types.
  2. Click “Add Product Variation Type”.
  3. Fill in the fields:
    • Label: T-Shirt Variations
    • ID: tshirt_variation (auto-generated)
    • Order item type: Default
  4. Click “Save”.

3.2 Add the “Size” Attribute

  1. Navigate to Commerce → Configuration → Product Attributes.
  2. Click “Add Product Attribute”.
  3. Fill in the details:
    • Label: Size
    • Attribute type: List (text)
    • Variation types: Select T-Shirt Variations
  4. Click “Save”.

3.3 Add Size Options

  1. After saving, go to the “Add values” section.
  2. Enter the size options one by one:
    • SM
    • MD
    • LG
    • XL
    • 2XL
    • 3XL
  3. Click “Save”.

3.4 Assign the Variation Type to the Product Type

  1. Navigate to Commerce → Configuration → Product Types.
  2. Click “Add Product Type”.
  3. Fill in:
    • Label: T-Shirt
    • Variation type: T-Shirt Variations
  4. Click “Save”.

Now, when adding a T-shirt product, you can create variations with different sizes!

 

 

4. Set Up Taxes for All 50 US States

Drupal Commerce 3.x has better tax integration. You can manually configure tax rates or use an external provider.

4.1 Enable Tax Calculation

  1. Navigate to Commerce → Configuration → Taxes.
  2. Click Add Tax Rate → Select “Sales Tax”.
  3. Choose US State-based Taxation.
  4. Set tax rates manually for all 50 states or use a tax provider like Avalara/TaxJar.

4.2 Automatic Tax Calculation (Optional)

For automatic tax calculation, install a tax provider module:

composer require drupal/commerce_avatax

Then, configure it under Commerce → Configuration → Taxes.

 

 

5. Configure Automatic Shipping Calculation

5.1 Install and Enable Commerce Shipping

composer require drupal/commerce_shipping drush en commerce_shipping -y

5.2 Configure Shipping

  1. Go to Commerce → Configuration → Shipping.
  2. Click “Add Shipping Method”.
  3. Set Origin Address as:
    • 2000 S Mill Ave, Tempe, AZ 85282
  4. Choose Flat Rate or install real-time shipping providers.

5.3 Real-time Shipping Rates

To enable FedEx, UPS, or USPS, install their modules:

composer require drupal/commerce_fedex drupal/commerce_ups drupal/commerce_usps

Then configure API credentials under Commerce → Configuration → Shipping.

 

 

6. Test Your Store

  1. Add a T-shirt to the cart.
  2. Proceed to checkout.
  3. Verify:
    • Taxes apply based on the shipping address.
    • Shipping costs are calculated from Tempe, AZ.

Your Drupal Commerce T-shirt store is now ready!