Skip to content

Commit

Permalink
Bump to version 2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
imagehat committed Sep 11, 2019
1 parent fd5493f commit 9dee033
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.0.6 - 2019-09-11
### Added
- Added a setting to disable sending partial refunds to AvaTax ([more](https://github.com/surprisehighway/craft-avatax#refunds))
- Added a json endpoint to use for ajax address validation on the front end ([more](https://github.com/surprisehighway/craft-avatax#ajax-address-validation))

### Fixed
- Fixed an issue where additional partial refunds would not be processed after the first because AvaTax requires unique document ids

## 2.0.5 - 2019-09-06
### Added
Expand Down
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,68 @@ You can use Craft's [plugin config file](https://docs.craftcms.com/v3/extend/plu
1. Copy `config.php` from the `avataxtax` directory to your craft/config folder and rename it to `avatax.php`
2. Update values in `avatax.php` and save.

## Ajax Examples

There is a JSON controller endpoint you can use for AJAX lookups/validation on the front-end. Currently the only endpoint is for address validation.

#### AJAX Address Validation

You can use an ajax lookup on the front-end to call the AvaTax [Resolve Address API](https://developer.avalara.com/avatax/address-validation/). Note if you implement this on the front-end you may want to disable address validation in the plugin settings to avoid more API calls during the checkout process (the JSON endpoint will still work).

This example uses the default Commerce 2 address form fields and jQuery to perform the AJAX call to give you a starting point, however jQuery is not required and it is up to you to implement as your checkout flow requires.

```
{% js %}
$('#address-form').on('submit.addressValidation', function(e) {
e.preventDefault();
var $form = $(this);
var data = {
address1 : $('[name="shippingAddress[address1]"]').val(),
address2 : $('[name="shippingAddress[address2]"]').val(),
city : $('[name="shippingAddress[city]"]').val(),
zipCode : $('[name="shippingAddress[zipCode]"]').val(),
stateValue : $('[name="shippingAddress[stateValue]"]').val(),
countryId : $('[name="shippingAddress[countryId]"]').val()
};
var csrfTokenName = "{{ craft.app.config.general.csrfTokenName }}";
var csrfTokenValue = "{{ craft.app.request.csrfToken }}";
data[csrfTokenName] = csrfTokenValue;
$.ajax({
type: 'post',
url: '/actions/avatax/json/validate-address',
data: data,
dataType: 'json'
}).done(function(data){
console.log(data);
if(data.success) {
// valid address
$form.off('submit.addressValidation').submit();
} else {
// handle error here...
return false;
}
});
});
{% endjs %}
```

## AvaTax Plugin Roadmap

Some things to do, and ideas for potential features:

* Better exception handling
* Json endpoint for address validation
* Config settings for default tax codes at the Product Type level.

---
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "surprisehighway/craft-avatax",
"description": "Calculate and add sales tax to an order's base tax using Avalara's Avatax service.",
"type": "craft-plugin",
"version": "2.0.5",
"version": "2.0.6",
"keywords": [
"craft",
"cms",
Expand Down

0 comments on commit 9dee033

Please sign in to comment.