diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4658c20f..e1945234 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
## Changelog
+* 2.0.6 - 2016.12.2:
+ * Fix: Do not allow to add external products to cart.
+ * Fix: Fix external product url.
+ * Fix: Checkout fields validation.
+ * Fix: Checkout registration.
+ * Fix: Remove usage of `price` meta from purchasable products.
+ * Fix: Properly handle account creation errors on checkout.
* 2.0.5 - 2016.11.24:
* Fix: Updating customer on checkout page.
* Fix: Removed unnecessary filter.
diff --git a/jigoshop.php b/jigoshop.php
index 1426959f..36397be6 100755
--- a/jigoshop.php
+++ b/jigoshop.php
@@ -20,7 +20,7 @@
* Description: Jigoshop, a WordPress eCommerce plugin that works.
* Author: Jigoshop
* Author URI: http://www.jigoshop.com
- * Version: 2.0.5
+ * Version: 2.0.6
* Requires at least: 4.0
* Tested up to: 4.6.1
* Text Domain: jigoshop
diff --git a/readme.txt b/readme.txt
index 9d81c061..5edfd9b8 100755
--- a/readme.txt
+++ b/readme.txt
@@ -5,7 +5,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Requires at least: 4.0
Tested up to: 4.6.1
-Stable tag: 2.0.4.1
+Stable tag: 2.0.6
A feature-packed eCommerce plugin built upon WordPress core functionality ensuring excellent performance and customizability.
@@ -104,6 +104,13 @@ However, if you want priority, dedicated support from Jigoshop staff, we dp offe
== Changelog ==
+= 2.0.6 - 2016.12.2 =
+* Fix: Do not allow to add external products to cart.
+* Fix: Fix external product url.
+* Fix: Checkout fields validation.
+* Fix: Checkout registration.
+* Fix: Remove usage of `price` meta from purchasable products.
+* Fix: Properly handle account creation errors on checkout.
= 2.0.5 - 2016.11.24 =
* Fix: Updating customer on checkout page.
* Fix: Removed unnecessary filter.
diff --git a/src/Jigoshop/Core.php b/src/Jigoshop/Core.php
index 88809090..d8c49c6a 100755
--- a/src/Jigoshop/Core.php
+++ b/src/Jigoshop/Core.php
@@ -13,7 +13,7 @@
class Core
{
- const VERSION = '2.0.5';
+ const VERSION = '2.0.6';
const WIDGET_CACHE = 'jigoshop_widget_cache';
const TERMS = 'jigoshop_term';
diff --git a/src/Jigoshop/Core/Types/Product/External.php b/src/Jigoshop/Core/Types/Product/External.php
index 87f44979..c34931c4 100755
--- a/src/Jigoshop/Core/Types/Product/External.php
+++ b/src/Jigoshop/Core/Types/Product/External.php
@@ -5,6 +5,7 @@
use Jigoshop\Entity\Order\Item;
use Jigoshop\Entity\Product;
use Jigoshop\Entity\Product\External as Entity;
+use Jigoshop\Exception;
use Jigoshop\Helper\Render;
use Jigoshop\Helper\Scripts;
use WPAL\Wordpress;
@@ -97,13 +98,7 @@ public function addVariableSubtype($subtypes)
public function addToCart($value, $product)
{
if ($product instanceof Entity) {
- $item = new Item();
- $item->setName($product->getName());
- $item->setPrice($product->getPrice());
- $item->setQuantity(1);
- $item->setProduct($product);
-
- return $item;
+ throw new Exception(__('The external product cannot be added to cart', 'jigoshop'));
}
return $value;
diff --git a/src/Jigoshop/Entity/Product/External.php b/src/Jigoshop/Entity/Product/External.php
index 9841896a..eda5ccdb 100755
--- a/src/Jigoshop/Entity/Product/External.php
+++ b/src/Jigoshop/Entity/Product/External.php
@@ -159,8 +159,8 @@ public function getStateToSave()
case 'regular_price':
$toSave['regular_price'] = $this->regularPrice;
break;
- case 'url':
- $toSave['url'] = $this->url;
+ case 'external_url':
+ $toSave['external_url'] = $this->url;
break;
}
}
@@ -180,14 +180,11 @@ public function restoreState(array $state)
{
parent::restoreState($state);
- if (isset($state['price'])) {
- $this->price = (float)$state['price'];
- }
if (isset($state['regular_price'])) {
$this->regularPrice = $state['regular_price'] !== '' ? (float)$state['regular_price'] : '';
}
- if (isset($state['url'])) {
- $this->url = $state['url'];
+ if (isset($state['external_url'])) {
+ $this->url = $state['external_url'];
}
if (isset($state['sales_enabled'])) {
$this->sales->setEnabled((bool)$state['sales_enabled']);
diff --git a/src/Jigoshop/Entity/Product/Simple.php b/src/Jigoshop/Entity/Product/Simple.php
index 4d974c18..34e33787 100755
--- a/src/Jigoshop/Entity/Product/Simple.php
+++ b/src/Jigoshop/Entity/Product/Simple.php
@@ -173,9 +173,6 @@ public function restoreState(array $state)
{
parent::restoreState($state);
- if (isset($state['price'])) {
- $this->price = (float)$state['price'];
- }
if (isset($state['regular_price'])) {
$this->regularPrice = $state['regular_price'] !== '' ? (float)$state['regular_price'] : '';
}
diff --git a/src/Jigoshop/Entity/Product/Virtual.php b/src/Jigoshop/Entity/Product/Virtual.php
index 88fcfb27..a0aa8c4d 100755
--- a/src/Jigoshop/Entity/Product/Virtual.php
+++ b/src/Jigoshop/Entity/Product/Virtual.php
@@ -168,9 +168,6 @@ public function restoreState(array $state)
{
parent::restoreState($state);
- if (isset($state['price'])) {
- $this->price = (float)$state['price'];
- }
if (isset($state['regular_price'])) {
$this->regularPrice = $state['regular_price'] !== '' ? (float)$state['regular_price'] : '';
}
diff --git a/src/Jigoshop/Frontend/Page/Checkout.php b/src/Jigoshop/Frontend/Page/Checkout.php
index d8a81af2..4c403c65 100755
--- a/src/Jigoshop/Frontend/Page/Checkout.php
+++ b/src/Jigoshop/Frontend/Page/Checkout.php
@@ -423,7 +423,7 @@ private function createUserAccount()
return;
}
- $email = $_POST['jigoshop_order']['billing']['email'];
+ $email = $_POST['jigoshop_order']['billing_address']['email'];
$errors = new \WP_Error();
$this->wp->doAction('register_post', $email, $email, $errors);
@@ -451,22 +451,31 @@ private function createUserAccount()
));
}
+ if (is_wp_error($id)){
+ throw new Exception(sprintf(
+ __("Error Account creation failed: %s", 'jigoshop'),
+ $id->get_error_message($id->get_error_code())
+ ));
+ }
+
$this->wp->wpUpdateUser(array(
'ID' => $id,
'role' => 'customer',
- 'first_name' => $_POST['jigoshop_order']['billing']['first_name'],
- 'last_name' => $_POST['jigoshop_order']['billing']['last_name'],
+ 'first_name' => $_POST['jigoshop_order']['billing_address']['first_name'],
+ 'last_name' => $_POST['jigoshop_order']['billing_address']['last_name'],
));
$this->wp->doAction('jigoshop\checkout\created_account', $id);
// send the user a confirmation and their login details
if ($this->wp->applyFilters('jigoshop\checkout\new_user_notification', true, $id)) {
- $this->wp->wpNewUserNotification($id, $password);
+ $this->wp->wpNewUserNotification($id);
}
$this->wp->wpSetAuthCookie($id, true, $this->wp->isSsl());
- $customer = $this->cartService->getCurrent()->getCustomer();
- $customer->setId($id);
+ $cart = $this->cartService->getCurrent();
+ $customer = $this->customerService->find($id);
+ $customer->restoreState($cart->getCustomer()->getStateToSave());
+ $cart->setCustomer($customer);
}
/**
diff --git a/src/Jigoshop/Frontend/Page/Product.php b/src/Jigoshop/Frontend/Page/Product.php
index ac18262d..ca89eac3 100755
--- a/src/Jigoshop/Frontend/Page/Product.php
+++ b/src/Jigoshop/Frontend/Page/Product.php
@@ -66,7 +66,9 @@ public function __construct(Wordpress $wp, Options $options, ProductServiceInter
$wp->addFilter('jigoshop\cart\add', function ($item) use ($productService){
/** @var $item Item */
- $item->setKey($productService->generateItemKey($item));
+ if($item instanceof Item) {
+ $item->setKey($productService->generateItemKey($item));
+ }
return $item;
});
diff --git a/src/Jigoshop/Service/CartService.php b/src/Jigoshop/Service/CartService.php
index a06ed037..05d00da6 100755
--- a/src/Jigoshop/Service/CartService.php
+++ b/src/Jigoshop/Service/CartService.php
@@ -9,6 +9,7 @@
use Jigoshop\Entity\OrderInterface;
use Jigoshop\Entity\Session;
use Jigoshop\Exception;
+use Jigoshop\Factory\Customer;
use Jigoshop\Factory\Order as OrderFactory;
use Jigoshop\Frontend\Pages;
use Jigoshop\Helper\Country;
@@ -114,14 +115,12 @@ public function get($id)
if (!isset($this->carts[$id])) {
$cart = new Cart($this->options->get('tax.classes'));
$cart->setCustomer($this->customerService->getCurrent());
- $cart->getCustomer()
- ->selectTaxAddress($this->options->get('taxes.shipping') ? 'shipping' : 'billing');
+ $cart->getCustomer()->selectTaxAddress($this->options->get('taxes.shipping') ? 'shipping' : 'billing');
// Fetch data from session if available
$cart->setId($id);
$state = $this->getStateFromSession($id);
- unset($state['customer']);
if (isset($_POST['jigoshop_order']) && Pages::isCheckout()) {
$state = $this->getStateFromCheckout($state);
}
@@ -143,10 +142,7 @@ private function getStateFromSession($id)
if (isset($session[$id])) {
$state = $session[$id];
- if (isset($state['customer'])) {
- // Customer must be unserialized twice "thanks" to WordPress second serialization.
- $state['customer'] = unserialize($state['customer']);
- }
+ $state['customer'] = $this->customerService->getCurrent();
if (isset($state['items'])) {
$productService = $this->productService;
diff --git a/templates/admin/product/box/general/external.php b/templates/admin/product/box/general/external.php
index bfed365b..2bac9c1c 100755
--- a/templates/admin/product/box/general/external.php
+++ b/templates/admin/product/box/general/external.php
@@ -9,7 +9,7 @@