Setup¶
The Shopping Cart extension comes with some pre-configured examples of views/forms using SearchKit/FormBuilder.
However, because it is so flexible and data varies by each CiviCRM setup you will likely need to customise and modify those forms.
Anonymous (not logged in) users¶
Carts are supported for anonymous users as well as logged in contacts - the cart is tracked against the session instead of a contact_id until the cart is submitted.
To allow this, grant the "Access Shopping Cart" permission to the Anonymous role - it is not granted to anyone by default.
View My Shopping Cart¶
- Form: afsearchViewMyShoppingCart
- URL (frontend): civicrm/shoppingcart/view
This form should not require any additional configuration.
Note that "Bypass permissions" is required on the SearchKit table.
If you copy/rename the "View My Cart" SearchDisplay (eg. to further customise the columns),
add its name to the shoppingcart_cart_display_names setting so the cart_id filter still gets
applied automatically. It defaults to ['View_My_Cart_Table'] - the name of the SearchDisplay
that ships with this extension. For example:
Civi::settings()->set('shoppingcart_cart_display_names', ['View_My_Cart_Table', 'My_Custom_Cart_Table']);
Checkout button¶
- Form: afformShoppingCartCheckout
- URL (frontend): civicrm/shoppingcart/checkout
The form must contain one entity of "Cart1" configured as follows:
- Security: Form-based
- Allowed actions: Update
- Accept ID from URL: No
- Autofill: Current Cart
Payment form¶
Requires afform_payments extension.
- Form: To do
- URL (frontend): civicrm/shoppingcart/pay
To do: Write up requirements. Both checkout and Payment forms need to be form-based so they work/prefill etc. We should think about updating form permissions to use "Access shopping cart" instead of groups.
Other forms: - Thankyou form - Add items to cart (via searchkit grid/action + formbuilder submission) - Discounts - Existing pending payment