Presentation is loading. Please wait.

Presentation is loading. Please wait.


Similar presentations

Presentation on theme: "DRUPAL COMMERCE DEALING WITH ANY SHOPPING SCENARIO."— Presentation transcript:


2 INTRODUCTION Drupal Commerce adds the functionality online merchants need in a Drupal based site! Eg Cart, Checkout, Orders, Invoices, Shipping, Tax etc Created by Ryan Szrama, the author of Ubercart Like Drupal, acts as a framework which can be extended Distributions for catering to specific scenarios Built/supported by Commerce Guys 23,000 + active sites Growing Commerce specific contrib Huge potential

3 WHY DRUPAL COMMERCE Hands down beats most E-com solutions for anything CMS / Social etc Huge D7 contrib space which can be used in Commerce, Eg Image Galleries, Flags, Ratings, newsletters, support forums, blogs etc Powerful search with Search API, Facet API and Solr Good theme system / responsive - Omega Where it currently falls down Not as mature as existing solutions / not as tried and tested Actually still pretty complicated for a standalone simple store We all know Drupal and have been building CMS sites, why not start using our skills to tackle E Commerce?

4 DISTRIBUTIONS Commerce Kickstart Best introduction for commerce MartPlug Open Deals

5 COMMERCE DEPENDENCIES Views Rules Address field Entity API Why are these important? Existing ecosystem - lots of modules are entity-aware Use standard hooks/classes (eg EntityFieldQuery & Metadata Wrappers) Hmmmm tasty! Views & Rules…

6 COMMERCE ENTITIES ProductA node can have multiple Product reference fields, each contain price, SKU and other Product Attributes. Product Types allow for variations Customer ProfileCustomers Profiles contain billing & shipping information. Each user may have multiple profiles, eg Work or Home Address. OrderOrders can have multiple line item references and a single Customer Profile reference. Represents major states through the life of an order (Canceled, Cart, Pending, Complete). Line ItemUsed in Orders to store a product references or product specific fields. PaymentRecords details of the transaction such the state (pending / success / failure) which updates the order

7 COMMERCE FIELDS Status – cannot edit, from product module SKU – cannot edit, from product module Address – from Address contrib module Price Product reference Line item reference Customer profile reference Add Attributes as almost any field

8 ENTITY METADATA WRAPPERS Provided by Entity API Much of Commerce expects you to use entity metadata wrappers Used by Rules & Search API for their magic Benefits: Allows chaining Prevents hardcoded nesting Easier Looping Getters and Setters Some nice extra methods like access, validate etc Entity API takes an entity type and an entity object as parameters to create a new object which has many useful methods attached to aid in accessing and manipulating an entities properties and fields

9 ENTITY METADATA WRAPPERS EXAMPLES How to get the wrapper and see what's available: $wrapper = entity_metadata_wrapper('node', $node); dpm($wrapper->getPropertyInfo()); Helps get values without the nesting. Eg $node->field_name[LANGUAGE_NONE][0][value]; Becomes: $wrapper->field_name->value(); Set the field with: $wrapper->field_name->set(new value)

10 ENTITY METADATA WRAPPERS EXAMPLES Chaining Entity data with Audoloading $order_wrapper = entity_metadata_wrapper(commerce_order, $order); $address = $order_wrapper->commerce_customer_billing->commerce_customer_address- >value() Looping through a list: $order_wrapper = entity_metadata_wrapper(commerce_order', $order); foreach ($order_wrapper->commerce_line_item->value() as $item) { //$item is a fully loaded line item entity. //Get product fields $item->commerce_product->field_name->raw() }

11 ENTITYFIELDQUERY Provided by Drupal 7 Core API Query your entities and their field data without writing complex join queries or knowing the schemas. /** * Implements hook_commerce_product_can_delete(). */ function commerce_product_reference_commerce_product_can_delete($product) { // Use EntityFieldQuery to look for line items referencing this // product and do not allow the delete to occur if one exists. $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'commerce_line_item', '=') ->entityCondition('bundle', commerce_product_line_item_types(), 'IN') ->fieldCondition('commerce_product', 'product_id', $product->product_id, '=') ->count(); return $query->execute() == 0; }

12 VIEWS & RULES Views: Baskets, Checkout etc all built using Rules so can be extended Uses Views to make your Product listings / Catalogues Build those custom order reports etc pretty quickly Rules: Adjust Prices using Rules for different roles, dates Tax and Shipping rates use Rules so can be modified Expire Products with Rules Scheduling Remove Items from the Cart Manage Experience with Custom Messages & Emails

13 COMMERCE SPECIFIC CONTRIB commerce_addressbookAllows customers to ueuse previously entered addresses during checkout commerce_couponAdds coupons entity to be redeemed on orders and can be dependent on product / user / roles etc. Provides % or fixed price amounts. commerce_checkout_redirec t / commerce_checkout_login Registers users before checkout commerce_checkout_progre ss Provides a nice block that shows the checkout steps commerce_price_savings_for matter Display formatter for price to how savings, take into account tax etc dc_cart_ajaxBetter UX through ajax loading commerce_wishlistProvides wish list functionality commerce_reorderAllows a user to reorder past orders commerce_google_analyticsSend order data to Google Analytics

14 COMMERCE SCENARIO DEMOS Store needs Customizable products: Flower shop needs to allow customers to define a custom message and date of delivery. How to: The line item is fieldable with the contrib module commerce_custom_product and allows for use cases like business cards, event registrations or donations where customer input is required to be stored. The field is stored on the line item so its unique to a product. Demo: http://kickstart.localhost:8082/customproduct/custom-shoes#

15 COMMERCE SCENARIO DEMOS Store needs custom node / validation in checkout A shop requires customers agree to a terms of service before they can make a purchase How to: Using commerce_extra_panes allows any node to be added in to the checkout process and ordered. Once the node is added a checkout can be included via a hook form alter using validation to ensure the custom has agreed

16 COMMERCE SCENARIO RECIPES Subscription (membership site) 1.Install & configure role_expire 2.Setup a Member role with default expiration 3.Install & configure content_access to restrict view access to Members 4.Setup a Membership product 5.On order completion use Rules to Apply the Member role to the customer and depending on product set expiration time Alternatively Try commerce_sp – a feature module or commerce_subscription

17 COMMERCE SCENARIO RECIPES Virtual goods / Subscription Sell Product keys: commerce_product_key – allows attaching unique product keys to orders to unlock / activate software Sell files: commerce_file – allows commerce to sell file access Sell Individual Nodes: Similar approach to selling membership, however each product should have a node reference to the node which a customer is buying access to. Also use content_access Rules module so on completing as order, loop through the line items using a component, if a node reference is set grant access to the node for the customer

18 COMMERCE SCENARIO RECIPES Gamification Applicable for Forums, Support sites etc where users can earn points and the get discounts. Use commerce_userpoints to buy products with points or use them to discount purchases


Similar presentations

Ads by Google