Jun 22 2018
Jun 22
Go to the profile of Drupal Europe

Jun 22, 2018

The e-commerce industry continues to grow rapidly year over year, bringing more merchants online and driving larger profits. With that growth comes the increased need for rich content, innovative product merchandising, and integration into an ever increasing number of third party sales, marketing, and fulfillment tools. Drupal has always excelled as a platform for building unique customer experiences, and it continues to come into its own as an adaptive sales platform via projects like Drupal Commerce.

Photo by Mike Petrucci on Unsplash

This track includes content that helps merchants understand how to start and grow their online businesses, demonstrates to developers how to build ambitious e-commerce sites, and incorporates solution providers who improve the whole process via integrations.

In the e-commerce track you will learn how to start to sell online, how to grow your existing business and reach a wider audience, and the best tools to use for developing your platform.

The track is focused on the following topics:

  • Drupal vs other e-commerce solutions: comparison, the cost of entry and scale
  • What competitive advantages does Drupal bring to online merchants?
  • What are the benefits of Drupal-native eCommerce solutions vs. integrating external systems?
  • Case studies for unique or ambitious implementations of Drupal for e-commerce
  • Latest trends in eCommerce (e.g. payment, fulfillment, security, taxes, etc.)
  • Latest trends in building eCommerce websites (e.g. headless, multichannel, AI, etc.)

About industry tracks

As you’ve probably read in one of our previous blog posts, industry verticals are a new concept being introduced at Drupal Europe and replace the summits, which typically took place on Monday. At Drupal Europe these industry verticals are integrated with the rest of the conference — same location, same ticket and provide more opportunities to learn and exchange within the industry verticals throughout three days.

Now is the perfect time to buy your ticket for Drupal Europe. Session submission is only open for a few more days so please submit your sessions and if encourage others who have great ideas.

Please help us to spread the word about this awesome conference. Our hashtag is #drupaleurope.

To recommend speakers or topics please get in touch at [email protected].

About the Drupal Europe Conference

Drupal is one of the leading open source technologies empowering digital solutions in the government space around the world.

Drupal Europe 2018 brings over 2,000 creators, innovators, and users of digital technologies from all over Europe and the rest of the world together for three days of intense and inspiring interaction.

Location & Dates

Drupal Europe will be held in Darmstadtium in Darmstadt, Germany — which has a direct connection to Frankfurt International Airport. Drupal Europe will take place 10–14 September 2018 with Drupal contribution opportunities every day. Keynotes, sessions, workshops and BoFs will be from Tuesday to Thursday.

Aug 19 2013
Aug 19

The taxation rules that come with Drupal Commerce out of the box calculate VAT or sales tax for each line item without any conditions, so every item in the order is taxed. This works for many situations but if you have items which need to be tax exempt you're in trouble. But there is a relatively painless way around it using some rules and fields.

To start with create a new field on your product entity called Tax Exempt. Set it to be a Boolean, single on/off checkbox.

Create a field called Tax Exempt

Make sure the default value is not checked, we don't want things to be tax exempt by default. Also remember to hide this field in the Manage Display settings.

Now we have to set up the taxation rules to handle this. Make sure the Tax and Tax UI modules are turned on. Two tax types will be enabled by default: VAT and Sales tax. We're going to start by setting up a generic sales tax. Right now we're going to charge this sales tax for everything. Realistically in the United States, you need to only collect sales tax in the state you're doing business in. For more on this topic check out another post in our Drupal Commerce Tax Series, Conditional State Sales Tax.

Create a new tax, we'll call it Generic Sales Tax. Give it a rate of .07, this translates to 7%.

Create a new generic tax rate

We can click configure component and add our conditions. First we need to bring the Tax Exempt field into scope. In Rules you have to check for a field before you can query it. Our first rule will be to get to the Product entity.

Condition: Entity has field.

Data selector: commerce-line-item
Field: commerce_product

Rule condition: entity has field commerce-product

This gives us access to the product through rules. Our next rule will give us access to the Tax Exempt field.

Condition: Entity has field

Data selector: commerce-line-item:commerce-product
Field: field_tax_exempt (or whatever you called your field)

Rule condition: entity has field Tax Exempt

Now that we have access to our Tax Exempt field we can make sure tax exempt items are not taxed.

Condition: Data to compare

Data selector: commerce-line-item:commerce-product:field-tax-exempt
Operator: Equals
Data value: (checked)
Negate
What this does is create a NOT Data comparison. So as long as the product does not have the Tax Exempt field checked tax will be calculated.

Rule condition: field Tax Exempt is not checked

With these conditions taken into account when calculating sales tax from a line item creating tax exempt products is as easy as checking a box. Here are all of the tax exempt conditions together.

All conditions for exempting products from taxation

For information on how to handle sales tax by state see our article Handling Sales Tax Based on Order Address with Drupal Commerce.

Mar 30 2013
Mar 30

Few month ago I developed  a simple module called Commerce Order2pdf and then I also added custom tokens as you can read from this post Custom token creation for Drupal 7 and now I reviewed this module a bit and planned to add views field handler (This means I can create custom view with download links). 

So how did I implemented this?

First step was to edit commerce_order2pdf.module file and add hook_views_api. So I could start working with views.

/**
 * Implements hook_views_api().
 */
function commerce_order2pdf_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'commerce_order2pdf') . '/includes/views',
  );
}

Next one was to create subdirectories includes/views into my commerce_order2pdf folder (module folder).

After this I had to tell views about my data structure.
So I did created new file /includes/views/commerce_order2pdf.views.inc and added hook_views_data.

/**
 * Implements hook_views_data()
 */
function commerce_order2pdf_views_data() {
  $data = array();
  $data['commerce_order']['order2pdf_link'] = array(
    'field' => array(
      'title' => t('Download pdf order'),
      'help' => t('Provide a simple link to download the order.'),
      'handler' => 'commerce_order2pdf_handler_field_order_pdf_link',
    ),
  );
  return $data;
 }

In this array I did extended commerce_order group and added field handler class callback.

Now we will add a new file commerce_order2pdf_handler_field_order_pdf_link.inc to includes/views folder.

/**
 * Field handler to present an order pdf download link.
 */
class commerce_order2pdf_handler_field_order_pdf_link extends commerce_order_handler_field_order_link {
  function construct() {
    parent::construct();
  }

  function render($values) {
    $order = commerce_order_new();
    $order->order_id = $this->get_value($values, 'order_id');
    // Add hash key for a download link.
    $hash = hash('md5', $order->order_id . $values->commerce_order_created);

    $text = !empty($this->options['text']) ? $this->options['text'] : t('Download');
    return l($text, "order2pdf/{$order->order_id}/{$hash}");
  }
}

My last step is to say Drupal about these files in commerce_order2pdf.info

For this step I will just add two rows to my .info file. 

files[] = includes/views/commerce_order2pdf.views.inc
files[] = includes/views/commerce_order2pdf_link_handler.inc

Now you can add views download field to your view. (If you make thses changes after you enabled your module then you can just clear caches and it will work).

Edit 13. April 2013 
Just found a good videos

[embedded content]

[embedded content]

Jan 29 2012
Jan 29

Edit: Use the Inline entity form module that was created after this post was published.

This post will go over an example (yet fully functionally) module that shows how we can embed a commerce product form inside a node form, and have the node reference the commerce product - without horrible hacks.

The problem is obviously the fact that we don’t have commerce product ID nor a node ID, as none of those objects is saved. A second problem is how to actually embed the commerce product form inside the node form. Subform module solves both issues (with a little custom code help).

I won’t go over each line of code here, as the module is well documented, however I will explain the important steps.

In the node's form alter, we embed the commerce product, using Subform’s form element.

<?php
module_load_include
('inc', 'commerce_product', 'includes/commerce_product.forms');
$form['commerce_product_subform'] = array(
 
'#type' => 'subform',
 
'#subform_id' => 'commerce_product_ui_product_form',
 
'#subform_arguments' => array($commerce_product),
 
'#required' => TRUE,
 
'#weight' => 10,
);
?>

In the code above we embed the form, pass it a $product object, and say it is required - meaning Subform should do validation on the embedded form.
Next step, is adding submit handlers in the right order

<?php
// Set the first submit handler to be "subform_submit_all", so the
// commerce product will be created, before handing the submitted node
// se we can associate the node to the commerce product.
// The last submit handler is the original 'node_form_submit', which
// will get all the values already populated, and save the node.
if (empty($node->nid)) {
 
array_unshift($form['actions']['submit']['#submit'], 'subform_submit_all', 'commerce_product_subform_commerce_product_submit');
}
else {
 
// The node already exists, so we assume there is already a reference
  // to the commerce product, so just add "subform_submit_all" submit
  // handler, to make sure the commerce product can be edited.
 
array_unshift($form['actions']['submit']['#submit'], 'subform_submit_all');
}
?>

Noticed the emphasize on the “right order” above? That’s because we want Subform to first submit the commerce product form (thus the commerce product will be saved and have an ID), next we want our own submit handler to set the field reference from the node to the commerce product, and last we want the original node_form_submit() to save the node.

In the example module, you will notice that we also hide the commerce product title. The reason is that we can easily populate the title from the node's title (see commerce_product_subform_form_commerce_product_ui_validate()).

As bonus, the example module also has a CTools plugin, that allows you to add the subform to an node add/ edit page that was overriden by Page manager.

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web