Table of Contents for
Magento 2 - Build World-Class online stores

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Magento 2 - Build World-Class online stores by Jonathan Bownds Published by Packt Publishing, 2017
  1. Cover
  2. Table of Contents
  3. Magento 2 - Build World-Class online stores
  4. Magento 2 - Build World-Class online stores
  5. Credits
  6. Preface
  7. 1. Module 1
  8. 1. Magento Fundamentals
  9. XAMPP installation
  10. Magento
  11. Summary
  12. 2. Magento 2.0 Features
  13. An introduction to the Magento order management system
  14. Magento 2.0 command-line configuration
  15. The command-line utility
  16. Summary
  17. 3. Working with Search Engine Optimization
  18. Store configuration
  19. SEO and searching
  20. SEO catalog configuration
  21. Google Analytics tracking code
  22. Optimizing Magento pages
  23. Summary
  24. 4. Magento 2.0 Theme Development – the Developers' Holy Grail
  25. Magento 2.0 theme structure
  26. The Magento Luma theme
  27. Magento theme inheritance
  28. CMS blocks and pages
  29. Custom variables
  30. Creating a basic Magento 2.0 theme
  31. Summary
  32. 5. Creating a Responsive Magento 2.0 Theme
  33. Composer – the PHP dependency manager
  34. Building the CompStore theme
  35. CSS preprocessing with LESS
  36. Applying new CSS to the CompStore theme
  37. Creating the CompStore logo
  38. Applying the theme
  39. Creating CompStore content
  40. Customizing Magento 2.0 templates
  41. Summary
  42. 6. Write Magento 2.0 Extensions – a Great Place to Go
  43. Using the Zend framework
  44. Magento 2.0 extension structure
  45. Developing your first Magento extension
  46. The Twitter REST API
  47. The TweetsAbout module structure
  48. Using TwitterOAuth to authenticate our extension
  49. Developing the module
  50. Summary
  51. 7. Go Mobile with Magento 2.0!
  52. Adjusting the CompStore theme for mobile devices
  53. The Magento 2.0 responsive design
  54. The Magento UI
  55. Implementing a new CSS mixin media query
  56. Adjusting tweets about extensions for mobile devices
  57. Summary
  58. 8. Speeding up Your Magento 2.0
  59. Indexing and caching Magento
  60. Indexing and re-indexing data
  61. The Magento cron job
  62. Caching
  63. Fine-tuning the Magento hosting server
  64. Selecting the right Magento hosting service
  65. Apache web server deflation
  66. Enabling the expires header
  67. Minifying scripts
  68. Summary
  69. 9. Improving Your Magento Skills
  70. Magento knowledge center
  71. Improving your Magento skills
  72. Summary
  73. 2. Module 2
  74. 1. Magento 2 System Tools
  75. Installing Magento 2 sample data via GUI
  76. Installing Magento 2 sample data via the command line
  77. Managing Magento 2 indexes via the command line
  78. Managing Magento 2 cache via the command line
  79. Managing Magento 2 backup via the command line
  80. Managing Magento 2 set mode (MAGE_MODE)
  81. Transferring your Magento 1 database to Magento 2
  82. 2. Enabling Performance in Magento 2
  83. Configuring Redis for backend cache
  84. Configuring Memcached for session caching
  85. Configuring Varnish as the Full Page Cache
  86. Configuring Magento 2 with CloudFlare
  87. Configuring optimized images in Magento 2
  88. Configuring Magento 2 with HTTP/2
  89. Configuring Magento 2 performance testing
  90. 3. Creating Catalogs and Categories
  91. Create a Root Catalog
  92. Create subcategories
  93. Manage attribute sets
  94. Create products
  95. Manage products in a catalog grid
  96. 4. Managing Your Store
  97. Creating shipping and tax rules
  98. Managing customer groups
  99. Configuring inventories
  100. Configuring currency rates
  101. Managing advanced pricing
  102. 5. Creating Magento 2 Extensions – the Basics
  103. Initializing extension basics
  104. Working with database models
  105. Creating tables using setup scripts
  106. Creating a web route and controller to display data
  107. Creating system configuration fields
  108. Creating a backend data grid
  109. Creating a backend form to add/edit data
  110. 6. Creating Magento 2 Extensions – Advanced
  111. Using dependency injection to pass classes to your own class
  112. Modifying functions with the use of plugins – Interception
  113. Creating your own XML module configuration file
  114. Creating your own product type
  115. Working with service layers/contracts
  116. Creating a Magento CLI command option
  117. 3. Module 3
  118. 1. Planning for Magento
  119. Technical considerations
  120. Global-Website-Store methodology
  121. Planning for multiple stores
  122. Summary
  123. 2. Managing Products
  124. Managing products the customer focused way
  125. Creating products
  126. Managing inventory
  127. Pricing tools
  128. Autosettings
  129. Related products, up-sells, and cross-sells
  130. Importing products
  131. Summary
  132. 3. Designs and Themes
  133. The concept of theme inheritance
  134. Default installation of design packages and themes
  135. Installing third-party themes
  136. Inline translations
  137. Working with theme variants
  138. Customizing themes
  139. Customizing layouts
  140. Summary
  141. 4. Configuring to Sell
  142. Payment methods
  143. Shipping methods
  144. Managing taxes
  145. Transactional e-mails
  146. Summary
  147. 5. Managing Non-Product Content
  148. Summary
  149. 6. Marketing Tools
  150. Promotions
  151. Newsletters
  152. Using sitemaps
  153. Optimizing for search engines
  154. Summary
  155. 7. Extending Magento
  156. The new Magento module architecture
  157. Extending Magento functionality with Magento plugins
  158. Building your own extensions
  159. Summary
  160. 8. Optimizing Magento
  161. Indexing and caching
  162. Caching in Magento 2 – not just FPC
  163. Tuning your server for speed
  164. Summary
  165. 9. Advanced Techniques
  166. Version control
  167. Magento cron
  168. Backing up your database
  169. Upgrading Magento
  170. Summary
  171. 10. Pre-Launch Checklist
  172. System configurations
  173. Design configurations
  174. Search engine optimization
  175. Sales configurations
  176. Product configurations
  177. Maintenance configurations
  178. Summary
  179. Index

Shipping methods

Once you get paid for a sale, you need to fulfill the order and that means you have to ship the items purchased. How you ship products is largely a function of what shipping methods you make available to your customers.

Shipping is one of the most complex aspects of e-commerce, and one where you can lose money if you're not careful. As you work through your shipping configurations, it's important to keep in mind the following:

  • What you charge your customers for shipping does not have to be exactly what you're charged by your carriers. Just as you can offer free shipping, you can also charge flat rates based on weight or quantity, or add a surcharge to "live" rates.
  • By default, Magento does not provide you with highly sophisticated shipping rate calculations, especially when it comes to "dimensional" shipping. Consider shipping rate calculations as estimates only. Consult with whomever is actually doing your shipping to determine if any rate adjustments should be made to accommodate dimensional shipping.

    Note

    Dimensional shipping refers to a recent change by UPS, FedEx, and others to charge you the greater of two rates: the cost based on weight or the cost based on a formula to determine the equivalent weight of a package based on its size: (Length x Width x Height) ÷ 166 (for US domestic shipments; other factors apply for other countries and exports). Therefore, if you have a large package that doesn't weigh much, the live rate quoted in Magento might not be reflective of your actual cost once the dimensional weight is calculated. If your packages may be large and lightweight, consult your carrier representative or shipping fulfillment partner for guidance.

  • If your shipping calculations need more sophistication than provided natively in Magento 2, consider an add-on. However, remember that what you charge to your customers does not have to be what you pay. For that reason — and to keep it simple for your customers — consider offering table rates (as described later).

    Tip

    WebShopApps (http://webshopapps.com) is perhaps the pre-eminent Magento shipping add-on provider. More recently, they have created a hosted shipping configuration system called ShipperHQ (https://shipperhq.com), which we have used to configure some rather complex shipping rules. If your shipping rules are more than Magento can natively accommodate, you may want to check these out.

  • Each method you choose will be displayed to your customers if their cart and shipping destination matches the conditions of the method. Take care not to confuse your customers with too many choices: simpler is better.

Keeping these insights in mind, let's explore the various shipping methods available by default in Magento 2.

Before we go over the shipping methods, let's go over some basic concepts that will apply to most, if not all, shipping methods.

Origin

Where you ship your products from will determine shipping rates, especially for carrier rates (for example, UPS, FedEx). To set your origin, go to Stores | Configuration | Sales | Shipping Settings and expand the Origin panel. At the very least, enter the Country, Region/State and ZIP/Postal Code field. The others are optional for rate calculation purposes.

Origin

At the bottom of this panel is the choice to Apply Custom Shipping Policy. If enabled, a field will appear where you can enter text about your overall shipping policy. For instance, you may want to enter Orders placed by 12:00 PM CT will be processed for shipping on the same day. Applies only to orders placed Monday-Friday, excluding shipping holidays.

Handling fee

You can add an invisible handling fee to all shipping rate calculations. Invisible in that it does not appear as a separate line item charge to your customers. To add a handling fee to a shipping method:

  • Choose whether you wish to add a fixed amount or a percentage of the shipping cost
  • If you choose to add a percentage, enter the amount as a decimal number instead of a percentage (for example, 0.06 instead of 6%)

Allowed countries

As you configure your shipping methods, don't forget to designate to which countries you will ship. If you only ship to the US and Canada, for instance, be sure to have only those countries selected. Otherwise, you'll have customers from other countries placing orders you will have to cancel and refund.

Method not available

In some cases, the method you configured may not be applicable to a customer based on destination, type of product, weight, or any number of factors. For these instances, you can choose to:

  • Show the method (for example, UPS, USPS, DHL, and so on), but with an error message that the method is not applicable
  • Don't show the method at all

Tip

Depending on your shipping destinations and target customers, you may want to show an error message just so the customer knows why no shipping solution is being displayed. If you don't show any error message and the customer disqualifies for any shipping method, the customer will be confused.

Free shipping

There are several ways to offer free shipping to your customers. If you want to display a Free Shipping option to all customers whose carts meet a minimum order amount (not including taxes or shipping), enable this panel.

However, you may want to be more judicious in how and when you offer free shipping. Other alternatives include:

  • Creating shopping cart promotions (see Chapter 6, Marketing Tools)
  • Include a free shipping method in your table rates (see later in this section)
  • Designate a specific free shipping method and minimum qualifying amount within a carrier configuration (such as UPS and FedEx).

If you choose to use this panel, note that it will apply to all orders. Therefore, if you want to be more selective, consider one of the above methods.

Flat rate

As with free shipping, above, the Flat Rate panel allows you to charge one, singular flat rate for all orders regardless of weight or destination. You can apply the rate on a per item or per order basis, as well.

Table rates

While using live carrier rates can provide more accurate shipping quotes for your customers, you may find it more convenient to offer a series of rates for your customers at certain break points.

For example, you might only need something as simple as follows, for any domestic destination:

  • 0-5 lbs, $5.99
  • 6-10 lbs, $8.99
  • 11+ lbs, $10.99

Let's assume you're a US-based shipper. While these rates will work for you when shipping to any of the contiguous 48 states, you need to charge more for shipments to Alaska and Hawaii. For our example, let's assume tiered pricing of $7.99, $11.99, and $14.99 at the same weight breaks.

All of these conditions can be handled using the table rates shipping method. Based on our example, we would first start by creating a spreadsheet (in Excel or Numbers) similar to the following:

Country

Region/State

Zip/Postal code

Weight (and above)

Shipping price

USA

*

*

0

5.99

USA

*

*

6

8.99

USA

*

*

11

10.99

USA

AK

*

0

7.99

USA

AK

*

6

11.99

USA

AK

*

11

14.99

USA

HI

*

0

7.99

USA

HI

*

6

11.99

USA

HI

*

11

14.99

Let's review the columns in this chart:

  • Country: Here, you would enter the three-character country code (for a list of valid codes, see http://goo.gl/6A1woj).
  • Region/State: Enter the two-character code for any state or province.
  • Zip/Postal code: Enter any specific postal codes for which you wish the rate to apply.
  • Weight (and above): Enter the minimum applicable weight for the range. The assigned rate will apply until the weight of the cart products combined equals a higher weight tier.
  • Shipping price: Enter the shipping charge you wish to provide to the customer. Do not include the currency prefix (for example, "$" or "€").

Now, let's discuss the asterisk (*) and how to limit the scope of your rates. As you can see in the chart, we have only indicated rates for US destinations. That's because there are no rows for any other countries. We could easily add rates for all other countries, simply by adding rows with an asterisk in the first column. By adding those rows, we're telling Magento to use the US rates if the customer's ship-to address is in the US, and to use other rates for all other country destinations.

Likewise for the Region/State column, Magento will first look for matches for any state codes listed. If it can't find any, then it will look for any rates with an asterisk. If no asterisk is present for a qualifying weight, then no applicable rate will be provided to the customer.

The asterisk in the Zip/Postal code column means that the rates apply to all postal codes for all states.

Note

To get a sample file with which to configure your rates, you can set your configuration scope to one of your websites (furniture or sportswear in our examples) and click Export CSV in the Table Rates panel.

Quantity- and price-based rates

In the above example, we used the weight of the items in the cart to determine shipping rates. You can also configure table rates to use calculations based on the number of items in the cart or the total price of all items (less taxes and shipping).

To set up your chart, simply rename the fourth column Quantity (and above) or Subtotal (and above).

Save your rate table

To upload your table rates, you'll need to save/export your spreadsheet as a CSV file. You can name it whatever you like. Save it to your computer where you can find it for the next steps.

Table rate settings

Before you upload your new rates, you should first set your table rates configurations. To do so, you can set your default settings at the default configuration scope. However, to upload your CSV file, you will need to switch your store view to the appropriate website scope.

Table rate settings

When changing to a website scope, you will see the Export CSV button and the ability to upload your rate table file. You'll note that all other settings may have Use Default checked. You can, of course, uncheck this box beside any field and adjust the settings according to your preferences.

Let's review the unique fields in this panel:

  • Enabled: Set to Yes to enable table rates
  • Title: Enter the name you wish displayed to customers when they're presented with a table rate-based shipping charge in the checkout process
  • Method Name: This name is presented to the customer in the shopping cart

    Tip

    You should probably change the default Table Rate to something more descriptive, as this term is likely irrelevant to customers. We have used terms Standard Ground, Economy, or Saver as names. The Title should probably be the same, as well, so that the customer, during checkout, has a visual confirmation of their shipping choice.

  • Condition: This allows you to choose the calculation method you want to use. Your choices, as we described earlier, are Weight vs. Destination, Price vs. Destination, and # of items vs. Destination.
  • Include Virtual Products in Price Calculation: Since virtual products (see Chapter 2, Managing Products) have no weight, this will have no effect on rate calculations for weight-based rates. However, it will affect rate calculations for price or quantity-based rates.

Once you have your settings, click on Save Config.

Upload rate table

Once you have saved your settings, you can now click the button next to Import and upload your rate table. Be sure to test your rates to see that you have properly constructed your rate table.

Carrier methods

The remaining shipping methods involve configuring UPS, USPS, FedEx, and/or DHL to provide "live" rate calculations. UPS is the only one that is set to query for live rates without the need for you to have an account with the carrier. This is both good and bad. It's good, as you only have to enable the shipping method to have it begin querying rates for your customers. On the flip side, the rates that are returned are not negotiated rates. Negotiated rates are those you may have been offered as discounted rates based on your shipping volume.

FedEx, USPS, and DHL require account-specific information in order to activate. This connection with your account should provide rates based on any discounts you have established with your carrier. If you wish to use negotiated rates for UPS, you may have to find a Magento add-on that will provide a modified rate query.