Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dealing with any shopping scenario

Similar presentations


Presentation on theme: "Dealing with any shopping scenario"— Presentation transcript:

1 Dealing with any shopping scenario
Drupal commerce Dealing with any shopping scenario

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 Like how Drupal gives you content types, taxonomies, menus and roles to manage most website requirements, commerce gives you carts, checkouts, orders, tax etc Created by Ryan Szrama author of Ubercart so very much the D7 successor Like Drupal its not ideal off the shelf but that weakness is also its power as its just as extensible as Drupal The Weakness can be plugged with distro – if anyone can be bothered putting the effort in! Commerce guys to Commerce are like Acquia to Drupal – nice to have a place to turn and provides credibility in enterprise

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? Its built on D7, so it has deep integration with the systems you know and love, fields, views, rules and entities Opportunity – chance to get in on something still fairly new and continue Drupals rocketing growth as it not only takes over the non – cms space but now starts to invade the Commerce space too. Which for us as Drupalists can only be a good thing.

4 Distributions Commerce Kickstart Best introduction for commerce
MartPlug Open Deals Distributions are pretty weak to be honest, however they can provide insight into particular implementations ! Go over each demo

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… So that deep integration comes from how close Commerce sits on Drupal 7. Has anyone had a problem trying to access Webform submissions with views or use it with Rules? It can cause real frustration due to webform being “bolted on top Drupal” or semi using it, eg uses form api but doesn’t use entities or fields. Why have webform components when contrib already provides a huge array of fields? This approach for me is what Wordpress follows where each plugin developer does their own thing but doesn’t really Metadata wrappers saves that nasty hardcoded nesting Everything is entities, Product, Customer Profile, Line item, Order Payment

6 Commerce entities Product
A node can have multiple Product reference fields, each contain price, SKU and other Product Attributes. “Product Types” allow for variations Customer Profile Customers Profiles contain billing & shipping information. Each user may have multiple profiles, eg Work or Home Address. Order Orders 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 Item Used in Orders to store a product references or product specific fields. Payment Records 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 You create a new wrapper using the node, you can see all the properties both fields and entity properties by outputting the getpropertyinfo Extra methods like access where you can findout if view / edit access is available for a user

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”) You create a new wrapper using the node, you can see all the properties both fields and entity properties by outputting the getpropertyinfo

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() } You create a new wrapper using the node, you can see all the properties both fields and entity properties by outputting the getpropertyinfo

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; } Problem with fieldable entities is that it is spread across a huge amount of tables which makes traditional methods of retrieving the values a bit of a join nightmare. Very cumbersome when you deal with revisions and languages too. Can find data objects condtional on entit type, bundle, properties or field values. The example uses entityfieldquery to check if any line items exist which reference a product and if they do then return false With commerce it pretty much becomes essential due to the nature of the spread out entitys and references

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 & s

13 Commerce specific contrib
commerce_addressbook Allows customers to ueuse previously entered addresses during checkout commerce_coupon Adds coupons entity to be redeemed on orders and can be dependent on product / user / roles etc. Provides % or fixed price amounts. commerce_checkout_redirect / commerce_checkout_login Registers users before checkout commerce_checkout_progress Provides a nice block that shows the checkout steps commerce_price_savings_formatter Display formatter for price to how savings, take into account tax etc dc_cart_ajax Better UX through ajax loading commerce_wishlist Provides wish list functionality commerce_reorder Allows a user to reorder past orders commerce_google_analytics Send 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:

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) Install & configure “role_expire” Setup a “Member” role with default expiration Install & configure content_access to restrict view access to Members Setup a “Membership” product 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


Download ppt "Dealing with any shopping scenario"

Similar presentations


Ads by Google