Basic Cart
A simple shopping cart and checkout system for Drupal that sends email notifications after orders and provides cart management blocks.
basic_cart
Install
composer require 'drupal/basic_cart:8.x-8.11'
Overview
Basic Cart is a lightweight e-commerce solution designed for small websites that need simple shopping cart functionality without the complexity of full commerce platforms. It allows site administrators to enable "Add to cart" functionality on any content type, making it ideal for selling products, services, or touristic offers.
The module automatically creates an order content type (basic_cart_order) to store customer information and purchased items. When a customer completes checkout, the system sends configurable email notifications to both the site administrator and the customer. Cart data can be stored in either session storage or database tables (for logged-in users who want persistent carts).
Basic Cart supports price display with customizable currency formatting, VAT/tax calculations, and quantity management. It provides two blocks: one showing cart contents with a "View cart" link, and another displaying just the cart item count with a visual cart icon.
Features
- Enable 'Add to cart' button on any selected content types through configuration
- Session-based cart storage with optional database persistence for logged-in users
- Configurable email notifications to administrators and customers upon order completion
- VAT/tax calculation support with percentage-based configuration
- Multiple price format options (8 different formats with currency positioning)
- Quantity management with increment/decrement on add to cart
- Cart block showing items, quantities, prices, and total
- Cart count block with customizable icon size and positioning
- Order content type with customer fields (name, email, phone, address, city, zipcode, message)
- Views-based admin interface for viewing and managing orders
- Custom thank you page with configurable title and message or redirect to custom URL
- Token support for email templates ([basic_cart_order:products], [basic_cart_order:basic_cart_total_price], etc.)
- AJAX-powered add to cart functionality with animated feedback
- Drush command to batch-enable add to cart for all nodes of enrolled types
- Bulk action to enable add to cart for selected nodes
Use Cases
Simple Product Catalog
A small business website selling a limited number of products (e.g., handmade crafts, local produce). Create a 'Product' content type, enable it in Basic Cart settings, add product nodes with prices, and create a Views listing. Customers can add items to cart and checkout by providing contact information.
Service Booking Requests
A service business (e.g., consulting, home repairs) where customers can select services and request quotes. Create a 'Service' content type, enable add-to-cart, and customize the checkout form. Orders serve as service requests with customer contact information.
Event Ticket Reservations
A venue or event organizer allowing visitors to reserve tickets. Create an 'Event' content type with ticket price, enable quantity for multiple ticket purchases, and use the order system to collect attendee information.
Tourism Package Offers
A tourism website offering vacation packages or tours. Create a 'Tour Package' content type with pricing, enable add-to-cart, and let visitors build their trip by adding multiple packages to cart before checkout.
Digital Downloads Catalog
A website offering digital products (templates, ebooks, software). Create a 'Digital Product' content type with pricing. Since no shipping is needed, the basic checkout with email notification provides everything necessary for processing orders.
Tips
- Use the 'Add to cart with quantity' formatter on product display pages and the basic 'Add to cart' formatter on teaser/listing views for a cleaner interface.
- Create a custom view mode named 'basic_cart_order' for your product content types to control exactly what information appears in order emails and the orders admin view.
- Use the Cart Count Block in a floating/fixed position for persistent cart visibility across all pages.
- Configure the thank you page redirect to a custom URL if you want to show more detailed order confirmation or integrate with external systems.
- Use the bulk action 'Enable add to cart' from Views bulk operations to quickly enable add-to-cart on many existing products.
- Use the Drush command 'drush baca-en' to batch-enable add-to-cart on all nodes after initially enabling a content type.
Technical Details
Admin Pages 3
/admin/config/basic-cart/settings
Configure the main shopping cart settings including content types, currency, pricing, VAT, order options, and customizable text labels.
/admin/config/basic-cart/checkout
Configure email notifications sent to administrators and customers after order placement, and customize the thank you page.
/basic-cart-orders
Views-based administrative page displaying all placed orders in a table format with customer information, order contents, VAT, total price, and purchase date. Accessible via the admin menu.
Permissions 4
Hooks 1
hook_basic_cart_tokens
Provides custom tokens for use in email templates. The module defines tokens under the 'basic_cart_order' token type.
Drush Commands 1
drush basic-cart:enable-add-to-cart
Enable add to cart for all nodes of all enrolled content types. Processes nodes in batches of 50 to manage memory usage.
Troubleshooting 5
Ensure the content type is selected in Basic Cart settings (/admin/config/basic-cart/settings). Check that the 'Add to cart' field is enabled (checked) when editing the node. Also verify the display settings for the content type include the add_to_cart field.
Enable 'Persist cart data' option in Basic Cart settings. This stores cart in the database for logged-in users. Note that anonymous users always use session storage which clears on browser close.
Verify the admin email addresses in Checkout settings. Check that your site's mail system is properly configured. Review Drupal's recent log messages for any mail-related errors. Ensure 'Send an email to the customer' is checked if customer emails are expected.
Enable both 'Enable price' and 'Enable Currency' in cart settings. Select the appropriate price format. Ensure products have the add_to_cart_price field populated.
Ensure the 'Add to cart redirect' setting is empty or set to '<none>' for AJAX to work. Check browser console for JavaScript errors. Verify that core/drupal.ajax library is loading correctly.
Security Notes 4
- The module uses Drupal's standard permission system. Grant 'Use basic cart' permission carefully as it allows adding items and checkout.
- The 'Create Direct Orders' permission bypasses the cart entirely and should only be granted to trusted administrators.
- Order data is stored as nodes. Review and configure node access permissions appropriately for the basic_cart_order content type.
- Email addresses entered by customers are stored in the order nodes. Ensure appropriate access controls and consider GDPR compliance requirements.