Skip to content

Commit

Permalink
release 2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
kkasowski committed Dec 2, 2016
1 parent 5b3fa51 commit 46eff87
Show file tree
Hide file tree
Showing 25 changed files with 606 additions and 260 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion jigoshop.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Jigoshop/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
9 changes: 2 additions & 7 deletions src/Jigoshop/Core/Types/Product/External.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 4 additions & 7 deletions src/Jigoshop/Entity/Product/External.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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']);
Expand Down
3 changes: 0 additions & 3 deletions src/Jigoshop/Entity/Product/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] : '';
}
Expand Down
3 changes: 0 additions & 3 deletions src/Jigoshop/Entity/Product/Virtual.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] : '';
}
Expand Down
21 changes: 15 additions & 6 deletions src/Jigoshop/Frontend/Page/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -451,22 +451,31 @@ private function createUserAccount()
));
}

if (is_wp_error($id)){
throw new Exception(sprintf(
__("<strong>Error</strong> 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);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Jigoshop/Frontend/Page/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
10 changes: 3 additions & 7 deletions src/Jigoshop/Service/CartService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/product/box/general/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<fieldset class="<?php echo $product instanceof Product\External ? '' : 'not-active'; ?>">
<?php
Forms::text(array(
'name' => 'product[url]',
'name' => 'product[external_url]',
'label' => __('Product URL', 'jigoshop'),
'classes' => array('product-external'),
'placeholder' => __('Enter external product URL...', 'jigoshop'),
Expand Down
5 changes: 2 additions & 3 deletions templates/shop/list/cart/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
* @var $product \Jigoshop\Entity\Product\External Product to add.
*/
?>
<form action="<?php echo $product->getUrl(); ?>" method="get" class="form-inline cart" role="form" target="_blank">
<button class="btn btn-primary btn-block" type="submit"><?php _e('Buy product', 'jigoshop'); ?></button>
</form>
<?php do_action('jigoshop\template\product\before_cart', $product); ?>
<a class="btn btn-primary" target="_blank" href="<?php echo $product->getUrl(); ?>"><?php _e('Buy product', 'jigoshop'); ?></a>
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInitc1b1b78b4274136f36bff3e366cb19ea::getLoader();
return ComposerAutoloaderInit686ddfe1d7d54e7df1ed9e5a204f1480::getLoader();
6 changes: 3 additions & 3 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitc1b1b78b4274136f36bff3e366cb19ea
class ComposerAutoloaderInit686ddfe1d7d54e7df1ed9e5a204f1480
{
private static $loader;

Expand All @@ -19,9 +19,9 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInitc1b1b78b4274136f36bff3e366cb19ea', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit686ddfe1d7d54e7df1ed9e5a204f1480', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitc1b1b78b4274136f36bff3e366cb19ea', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit686ddfe1d7d54e7df1ed9e5a204f1480', 'loadClassLoader'));

$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
Expand Down
Loading

0 comments on commit 46eff87

Please sign in to comment.