[Drupal] How to configure Drupal commerce for Drupal 7 sites

| | 3 min read

Drupal Commerce is a software used for integrating commerce,
content and community to create engaging web experiences that bring
e-retailers more traffic for more results. With Drupal Commerce, online
retailers have a simple yet powerful platform and flexibility to
integrate a rich commerce experience anywhere within their environment.

Drupal Commerce installation.

Drupal Commerce provides retailers with a medium to sell their products and services.

  • To install Drupal commerce, install the module from the the following link,

    Using drush,
     drush en commerce -y; 

    I would personally suggest using drush to install the module, as it have many dependencies.

    Now got to admin -> modules, find commerce from the module list, and enable its dependencies.

  • Install 'Inline Entity Form' module, from https://www.drupal.org/project/inline_entity_form
    Install using drush,
     drush en inline_entity_form -y; 
  • After installing the module, you could see a new menu item 'store' on the admin bar.

    Now we can add products, but we are missing content type for product. aren't we?
    • Go to admin -> Structure -> Add content type
    • Create a new content type, say product.
    • Lets give its name as 'product' and 'Add product' as description.commerce-1.png
    • Now we are set to add fields.
    • By default, every content type have title and body.
    • Save Content type.
    • Now we are set to add own fields to the content type,
      • Product Image
        • Machine name is automatically generated for the field, would be like field_product_image.
        • Select field type and widget as Image. Click on save.
        • Moving on, here we can set a default image for products, so that this image will show for those products with no image.
          Click on Save Settings.
        • On this window, we can change the label from 'Product Image' to 'Image', as it looks good as a label.
        • Check the checkbox box for required field, if we want it to be mandatory. Sure it is.
        • Let it be mandatory, how come a customer buy a bag with out knowing how would it look like?.
        • Help Text for letting the user know the purpose of this field. Let it be like, 'Image of the product'.
        • Default Image is used when no image is uploaded. Lets leave it blank as we have already set the image field mandatory.
        • Allow file extensions, here we already loaded with few file extensions,
          if we want .swf flash files then include it to the end of the listing.
        • File Directory is where these files will be stored.
        • Minimum and Maximum image resolution defines the height and width of the image that we can upload for the field.
        • Maximum upload size - Size of the image.
        • Check Enable Alt and title if wanted.
        • Select 'Number of Values' as 1.

          Now finally set to save.
      • Color
        • Add next field, Color. Machine field is generated as field_product_color.
        • Lets select the filed type as List(text) and Widget as Select.
        • Go on and add the values to select from, Enter one value per line, in the format key|label. Save.
        • Change the label, Make it mandatory, Enter a help text, Set the default value from the list box. Save Settings.
      • Reference field
        • Select Product reference as the field type.
        • Here, we will get to know why we have installed inline conditions entity form module,
          Select Inline Entity Form - Single from list box as Widget and move on.
        • Lets leave options list limit empty as it is the limit for the number of products.
        • Here we have the changes in Label, Mandatory checkbox, Help text.
        • This is how it look like at the end. commerce-2.png
    • Add products at Admin-> Content -> Add Content -> Product.commerce-3.png
    • You can see the reference field in the add product page.

The module and its dependencies are mainly used in commerce sites,
were the owner can manage his/her products.