Aelia - Product update badge

Shipping Pricing for Currency Switcher – Improvements for WooCommerce 2.6 Beta 2

WooCommerce Shipping Pricing Integration – What’s new

Our Shipping Pricing Integration Add-on for WooCommerce Currency Switcher has been updated to version 1.2.3.160516. This update brings the following improvements and fixes:

  • Added support for new features introduced in WooCommerce 2.6 Beta 2. The Beta 2 of WooCommerce 2.6 introduced a new interface to edit the parameters of a shipping method. When the shop owner click on the Settings link on the Shipping Zone Methods page, a new popup window opens. This window allows to change the settings of a shipping method quickly, without reloading the entire page, like it was done in the past. You can see some screenshots of the new UI below:

    Unfortunately, although this new feature can improve the user experience, it also has significant drawbacks. The new popup window is generated using a JavaScript library called Backbone.js. We are not aware of the reasons behind this choice, but it’s fact that, unlike the traditional WooCommerce architecture, elements built with that library are far more complicated to extend, especially when more than one plugin comes into play.

    This presented a significant challenge to us, for our Shipping Integration was not designed to take into account the presence of such library. Although our plugin worked fine, even in WooCommerce 2.6, with the classic user interface, handling this new popup required a significant amount of work. Backward compatibility is of paramount importance to us, and we couldn’t just rewrite everything using the new library. Basically, we needed to find a solution that would work with WooCommerce 2.6 and earlier versions, seamlessly.
    Needless to say, we found a solution (at least, until new breaking changes are introduced). Our multi-currency selector can now work directly from a Shipping Zone Methods page, as well as on the popup window. We didn’t touch the Backbone code, as we find it too hard to tweak, and relied on a “trick” instead.

    Below you can find the result of our efforts, the new multi-currency interface for shipping methods:

    As you can see, we tried to keep the original interface as much as possible, and added our elements in a separate area. Simplicity is the key!

  • Fixed calculation of currency specific shipping in WC 2.6 Beta 2. The calculation was broken by unexpected changes in how shipping methods are handled when they are assigned to a zone. The new shipping zones are a new concept, and they seem to be a bit of a “moving target”. We will work on fixing all the bugs caused by breaking changes as soon as we discover them.

How to get latest version

New customers

Simply place your order and you will get the latest version.

Existing customers

You should be able to download the updated file using the link you received with your order. If the link doesn’t work, please contact Support to receive the latest version. Thanks.

Aelia - Product update badge

Easy Digital Downloads Currency Switcher – Support for Fees (Shipping and Recurring Payments)

Easy Digital Downloads Currency Switcher – What’s new

Currency Switcher for Easy Digital Downloads has been updated to version 1.4.3.160501. This update brings the following improvements and fixes:

  • Added logic to handle of EDD fees. We helped the EDD team extending the core of Easy Digital Downloads to allow the processing of fees, which may be added by 3rd party plugins. This new feature will make it possible to add multi-currency support to plugins like Simple Shipping and Recurring Payments.
  • Code cleanup. Conditionally removed filters that are obsolete in the new versions of EDD.
  • Improvements
    • Added logic to prevent double conversion of variations’ prices.
    • Fixed minor bug that could cause the historical order totals to appear as zero.

How to get latest version

New customers

Simply order the plugin from the product page and you will get the latest version.

Existing customers

You should be able to download the updated file using the link you received with your order. If the link doesn’t work, please contact Support to receive the latest version. Thanks.

Aelia - News badge

WooCommerce Tips & Tricks – Get all the categories to which a product belongs

As active contributors of several communities, such as the Advanced WooCommerce and WooCommerce Help & Share groups on Facebook, we came across a question that seem to be quite frequent.

How to get all of a product’s categories

This operation is simple, it just requires a bit more work than one would expect. It’s very easy to fetch the categories to which a product is assigned directly, but a product may also belong to parent categories (a parent category is a category to which a subcategory belongs). The screenshot below explains the concept.

Product category hierarchy

In this example, the product belongs directly to “Subcategory A1” and “Some other category”. It also belongs indirectly to “Category A”, as “Subcategory A1” is a child of that category.

In the above example, the product belongs to the following categories:

  • Directly to Subcategory A1 and Some other category, as it’s assigned directly to them.
  • Indirectly to Category A, which is the parent of Subcategory A1.

Now that the concepts are clear, let’s get coding.

Step 1 – Get the direct categories of a product

This is the easiest part. It’s just a matter to find all the “category” terms associated to a product. Our function will look like this:

function aelia_get_product_categories($product, $return_raw_categories = false) {
  $result = array();
  // Get all the categories to which a product is assigned
  $categories = wp_get_post_terms($product->id, 'product_cat');
  
  // The $categories array contains a list of objects. Most likely, we would 
  // like to have categorys slug as a keys, and their names as values. The#
  // wp_list_pluck() function is perfect for this
  $categories = wp_list_pluck($categories, 'name', 'slug');
  return $categories;
}

The result of this function, once applied to our example product, will be the following:

array(
  'subcategory-a1' => 'Subcategory A1',
  'some-other-category' => 'Some other category',
)

All good, we have the categories to which the product is assigned directly. Now we need to get all the parent categories.

Step 2 – Get the parent category (or categories) of a given category

To keep things tidy, we will create a second function to get the parent categories of a category. This requires a similar approach to the one used for the products.

function aelia_get_parent_categories($category_id) {
  $parent_categories = array();
  // This will retrieve the IDs of all the parent categories 
  // of a category, all the way to the top level
  $parent_categories_ids = get_ancestors($category_id, 'product_cat');
  
  foreach($parent_categories_ids as $category_id) {
    // Now we retrieve the details of each category, using its
    // ID, and extract its name
    $category = get_term_by('id', $category_id, 'product_cat');
    $parent_categories[$category->slug] = $category->name;
  }
  return $parent_categories;
}

The above will return the following result for Subcategory A1:

array(
  'category-a' => 'Category A'
)

As before, we have a list with category slugs as keys, and category names as values. Time to finish the job.

Step 3 – Putting the pieces together

Now that we can get both the direct categories of a product and their parent categories, we can alter the first function to call the second and give us a result that includes all the categories. The modified function will look as follows:

function aelia_get_product_categories($product, $return_raw_categories = false) {
  $result = array();
  $categories = wp_get_post_terms($product->id, 'product_cat');

  if(is_array($categories) && !$return_raw_categories) {
    $parent_categories = array();
    // Retrieve the parent categories of each category to which
    // the product is assigned directly
    foreach($categories as $category) {
      // Using array_merge(), we keep a list of parent categories
      // that doesn't include duplicates
      $parent_categories = array_merge($parent_categories, aelia_get_parent_categories($category->term_id));
    }
    // When we have the full list of parent categories, we can merge it with
    // the list of the product's direct categories, producing a single list
    $categories = array_merge($parent_categories, wp_list_pluck($categories, 'name', 'slug'));
  }
  return $categories;
}

As you will probably have guessed, the new function will return the following result:

array(
  'subcategory-a1' => 'Subcategory A1',
  'some-other-category' => 'Some other category',
  'category-a' => 'Category A',
)

That is, a list of all the direct and indirect categories to which a product belongs. Mission accomplished!

For your convenience, you can find the complete code here: WooCommerce – WooCommerce – Get product categories, including parent categories (Pastebin).

Need help?

Should you need help implementing the solution, or if you would need to have the category search functions implemented as part of a more complex custom project, please feel free to contact us. We will review your specifications and give you a quote for your customisation.

The Aelia Team

Aelia - News badge

SIP Frontend Bundler now supports Aelia Currency Switcher for WooCommerce

We are delighted to inform you that a new plugin joined the multi-currency family. The SIP Frontend Bundler, developed by ShopitPress, now includes full support for our ever popular Currency Switcher for WooCommerce. Together, they will grant you unprecedented flexibility in offering attractive bundles to your customers, helping you increasing your revenue.

What can the SIP Front End Bundler do for you?

In short, it allows your customers to configure and buy product bundles, straight from your front page. The price is updated in real time, so that the buyer can immediately see how much he is going to spend, and adjust the bundle accordingly. Easy to explain, easy to use!

Some of the exclusive features provided by the SIP Front End Bundler

  • Let customer crate their own bundle
    No need to spend time creating pre-configured bundles, one by one, hoping to get it “just right”. Just select the products that can be bundled together, and let your customers create their own set.
  • Real-time price display
    Customers like to know in advance how much they are going to spend, possibly without having to manually compare multiple product combinations. The SIP Frontend Bundler will show them how much they are saving in real-time, as the customer build its own bundle.
  • Build your bundle from anywhere
    The SIP Front End Bundler for WooCommerce can show the bundle builder in any page on your site. Your customers will love to create their own bundles right from the front page, instead of having to go through a long catalogue.
  • Fully supports the Aelia Currency Switcher
    Thanks to the collaboration between Aelia and ShopitPress, the SIP Front End Bundler includes full support for our Currency Switcher for WooCommerce. Sell your bundles in multiple currencies and increase conversion!

Multi-currency Bundles in WooCommerce, made easy!

This is another great result of a collaboration between teams who share the same vision, and who recognise the importance of being able to offer your products to a worldwide audience, catering to a large range of needs. Just like our Currency Switcher for WooCommerce, which was born to grant customers the flexibility to pay in their preferred currency, the SIP Front End Builder grants them the freedom to create their own special offers, quickly and easily.

We would like to thank the ShopitPress team for the effort they put in developing such a powerful, yet easy to use solution for the management and creation of bundles. Well done, and keep up the good work!

Are you a plugin developer?

If you are a plugin developer, and would like to learn how to add multi-currency capabilities to your products, please feel free to get in touch. We will be happy to give you the information you need for a quick start, as well as examples that will simplify the integration with our Currency Switcher for WooCommerce. You will join the ever-growing list of teams who support such an important feature, amongst which you can find SkyVerge, Prospress, YIThemes, ThemeComplete and, of course, ShopitPress.

Thanks for reading, and see you soon for more great news!

The Aelia Team

Aelia - News badge

WooCommerce Currency Switcher – Support for Composite Products

Following multiple requests from our customers, we have been working with the developers of the Bundles and Composite Products plugins to introduce full compatibility with our Currency Switcher for WooCommerce.

Support for bundles is currently provided by our free Bundles Integration Addon, which will work as a temporary solution while SomewhereWarm, the authors of the Bundles plugin, update their product. It may take a while before the same features are ported to the Composite Products plugin, therefore we decided to start testing that plugin in our environment, to determine which features should be added to make it support our Currency Switcher.

Composite Products – Compatibility Status

Our tests, performed with the Composite Products 3.6.4, indicated that the plugin is already quite compatible with our Currency Switcher. You can find more details below:

Products with per-item pricing

  • The prices of components are converted correctly. The conversion is performed on each component individually, before its price is used, and each component uses its currency-specific prices, where applicable.
  • Product’s base prices (regular and sale) are not yet converted. These values have been introduced recently, and they will have to be passed to the conversion functions.

Products with simple pricing

  • The price of the composite product is converted correctly, using exchange rates.
  • The prices in each currency are not saved, as the product requires a special processing for that purpose.

What’s next

We are going to run more tests and give the authors of the Composite Products plugin the information required to address the issues reported above.

Should we find out that it could take too long, we will try to write an addon, like the one we wrote for the Bundles plugin, as a temporary solution. If you would like to be informed when the addon is released, or you would like to contribute to its development, please feel free to contact us, and we will send you more details.

Update – 4th May 2016

The Composite Products Integration is now available, free of charge!

The Aelia Team