1 / 18

Drupal commerce

Drupal commerce. Dealing with any shopping scenario. 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

alicia
Télécharger la présentation

Drupal commerce

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  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 • http://drupal.org/project/commerce_kickstart • http://demo.commerceguys.com/ • MartPlug • http://drupal.org/project/martplug • http://demo.martplug.com/ • Open Deals • http://drupal.org/project/opendeals • http://opendealsapp.com/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 (egEntityFieldQuery & Metadata Wrappers) • Hmmmm tasty! Views & Rules…

  6. Commerce entities

  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

  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_productand 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) • 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

More Related