Table of Contents
Introduction
Having a wishlist feature on your Drupal Commerce website can increase customer engagement and sales. Today, we will go over the steps needed to implement this feature in your Drupal Commerce website.
Step 1: Create a Content Type
The first step is to create a content type for the wishlist. Go to Structure > Content Types > Add Content Type. Name the content type “Wishlist” and add any fields you would like to include, such as product image, name, and price.
Step 2: Create a View
Next, create a view that will serve as the customer’s wishlist page. Go to Structure > Views > Add View. Name the view “Wishlist” and select “Wishlist” as the content type. Add any fields you would like to include in the view, such as product image, name, and price. Make sure to also add the “Add to Cart” button so customers can easily add items to their cart from the wishlist page.
Step 3: Create a Relationship
In order for the “Add to Cart” button to work, you will need to create a relationship between the wishlist and the product. Go to the “Advanced” section of the view and click on “Add” next to “Relationships”. Select “Wishlist Product” and save the relationship.
Step 4: Create an Add to Wishlist Button
Now we will create a button that customers can click to add products to their wishlist. Go to Structure > Commerce > Order Types > Default and click on the “Manage Display” tab. Add a new field called “Add to Wishlist” and set the label to “Add to Wishlist”. In the “Custom Display Settings” section, make sure to select “Wishlist” as the display target.
Step 5: Create a Rule
Next, create a rule that will add the product to the customer’s wishlist when they click the “Add to Wishlist” button. Go to Configuration > Workflows > Rules > Add Rule. Name the rule “Add to Wishlist” and set the event to “Completing the Add to Cart form”. Add a condition that will check if the “Add to Wishlist” button was clicked. Under the “Actions” section, select “Create a new Wishlist” and set the “Product” field to the product that was added to the cart.
Step 6: Add the Add to Wishlist Button
Finally, add the “Add to Wishlist” button to your product pages. Go to Products > Manage Products and select the product you want to add the button to. Under the “Display Settings” section, select “Wishlist” as the display target. In the “Custom Display Settings” section, add the “Add to Wishlist” field we created earlier.
Conclusion
By following these steps, you can easily implement a wishlist feature on your Drupal Commerce website. This feature can help increase customer engagement and sales, as well as provide a better user experience for your customers.