Skip to content

Commit

Permalink
release 2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kkasowski committed May 25, 2017
1 parent 6225095 commit 456c107
Show file tree
Hide file tree
Showing 30 changed files with 273 additions and 116 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## Changelog
* 2.1.3 - 2017.05.25:
* New: Allow to prepend product permalink with Wordpress permalink.
* New: Tool to fix order items migration.
* Fix: Fatal error on order edit page caused by Free shipping.
* Fix: Properly migrate order items.
* Fix: Discount migration.
* 2.1.2 - 2017.05.11:
* New: Possibility to get country code in ISO 3166-1 alfa-3 standard.
* Fix: Properly display custom settings tabs.
Expand Down
4 changes: 2 additions & 2 deletions assets/js/vendors/bs_tab_trans_tooltip_collapse.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions jigoshop.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* Description: Jigoshop, a WordPress eCommerce plugin that works.
* Author: Jigoshop
* Author URI: http://www.jigoshop.com
* Version: 2.1.2
* Version: 2.1.3
* Requires at least: 4.0
* Tested up to: 4.7.4
* Tested up to: 4.7.5
* Text Domain: jigoshop
* Domain Path: /languages/
*
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Tags: ecommerce, wordpress ecommerce, store, shop, shopping, cart, checkout, wid
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XTG9C24KAA7VA

Requires at least: 4.0
Tested up to: 4.7.4
Stable tag: 2.1.1
Tested up to: 4.7.5
Stable tag: 2.1.3

A feature-packed eCommerce plugin built upon WordPress core functionality ensuring excellent performance, customizability and control - robust Tax Settings, Stock Level Management, Free and Premium Extensions - you name it.

Expand Down
12 changes: 6 additions & 6 deletions src/Jigoshop/Admin/Migration/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function migrate($orders)
$value = is_array($value) ? serialize($value) : $value;
$wpdb->insert($wpdb->prefix . 'jigoshop_order_discount_meta', [
'discount_id' => $discountId,
'meta_mey' => $key,
'meta_key' => $key,
'meta_value' => $value,
]);
}
Expand Down Expand Up @@ -350,13 +350,13 @@ public function migrate($orders)
$itemData['qty'] = 1;
}

$price = $itemData['cost'] / $itemData['qty'];
$cost = $itemData['cost'] * $itemData['qty'];
if (!empty($itemData['taxrate']) && $itemData['taxrate'] > 0) {
$tax = $price * $itemData['taxrate'] / 100;
$tax = $cost * $itemData['taxrate'] / 100;
$taxRate = $itemData['taxrate'];
} else {
if (isset($itemData['cost_inc_tax']) && $itemData['cost'] < $itemData['cost_inc_tax']) {
$tax = ($itemData['cost_inc_tax'] - $itemData['cost']) / $itemData['qty'];
$tax = ($itemData['cost_inc_tax'] - $itemData['cost']) * $itemData['qty'];
$taxRate = $tax / $itemData['cost'];
}
}
Expand All @@ -379,10 +379,10 @@ public function migrate($orders)
'product_type' => $productGetType,
'title' => $itemData['name'],
'tax_classes' => '',
'price' => $price,
'price' => $itemData['cost'],
'tax' => $tax,
'quantity' => $itemData['qty'],
'cost' => $itemData['cost'],
'cost' => $cost,
];

if ($productGetId != null) {
Expand Down
5 changes: 4 additions & 1 deletion src/Jigoshop/Admin/Permalinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function settings()

$helpers = $this->wp->getHelpers();
$permalink = $helpers->trailingslashit($this->options->get('permalinks.product'));
$with_front = $this->options->get('permalinks.with_front');

// Get shop page
$shopPageId = $this->options->getPageId(FrontendPages::SHOP);
Expand All @@ -101,6 +102,7 @@ public function settings()
'base' => $base,
'productBase' => $productBase,
'homeUrl' => $this->wp->getHomeUrl(),
'with_front' => $with_front,
]);
}

Expand All @@ -120,6 +122,7 @@ private function save()
$helpers = $this->wp->getHelpers();
$permalinks['category'] = $helpers->untrailingslashit($categorySlug);
$permalinks['tag'] = $helpers->untrailingslashit($tagSlug);
$permalinks['with_front'] = isset($_POST['product_permalink_with_front']) && $_POST['product_permalink_with_front'] == 'on';

// Product base
$product_permalink = trim(strip_tags($_POST['product_permalink']));
Expand All @@ -144,7 +147,7 @@ private function save()
if ($shopPageId && trim($permalinks['product'], '/') === $shop_permalink) {
$permalinks['verbose'] = true;
}

$this->options->update('permalinks', $permalinks);
$this->options->saveOptions();
$this->wp->getRewrite()->flush_rules();
Expand Down
42 changes: 40 additions & 2 deletions src/Jigoshop/Admin/SystemInfo/ToolsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ public function getSections()
return Render::output('admin/system_info/tool', $field);
}
],
[
'id' => 'fix-order-items-migration',
'name' => 'fix-order-items-migration',
'title' => __('Fix order items migration', 'jigoshop'),
'description' => __('To version 2.1.3 was some issue with order items migration. Use only if you migrated your store from Jigoshop 1.x before version 2.1.3.', 'jigoshop'),
'tip' => '',
'classes' => [],
'type' => 'user_defined',
'display' => function($field){
return Render::output('admin/system_info/tool', $field);
}
],
]
]
];
Expand Down Expand Up @@ -144,6 +156,9 @@ private function processRequest($request)
case 'remove-zombie-meta':
$this->removeZombieMeta();
break;
case 'fix-order-items-migration':
$this->fixMigratedOrderItems();
break;
}
}

Expand All @@ -154,8 +169,8 @@ private function clearLogs()
{
$logFiles = $this->wp->applyFilters('jigoshop/admin/system_info/tools/log_files', ['jigoshop', 'jigoshop.debug']);
foreach($logFiles as $logFile){
if (@fopen(JIGOSHOP_LOG_DIR.'/'.$logFile.'.log', 'a')) {
file_put_contents(JIGOSHOP_LOG_DIR.'/'.$logFile.'.log', '');
if (@fopen(\JigoshopInit::getLogDir().'/'.$logFile.'.log', 'a')) {
file_put_contents(\JigoshopInit::getLogDir().'/'.$logFile.'.log', '');
}
}
}
Expand Down Expand Up @@ -190,4 +205,27 @@ private function removeZombieMeta()
(SELECT * FROM {$wpdb->posts} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)
");
}

/**
* Fix migration issue.
*/
private function fixMigratedOrderItems()
{
set_time_limit(0);
$wpdb = $this->wp->getWPDB();
$js1Orders = $wpdb->get_results("SELECT post_id as id FROM {$wpdb->postmeta} WHERE meta_key = 'order_items'", ARRAY_A);

foreach($js1Orders as $order) {
$items = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}jigoshop_order_item WHERE order_id = %d", $order['id']), ARRAY_A);
foreach ($items as $item) {
$taxRate = $item['tax']/ $item['price'];
$item['price'] = $item['cost'];
$item['cost'] = $item['price'] * $item['quantity'];
$item['tax'] = $item['cost'] * $taxRate;
$wpdb->update("{$wpdb->prefix}jigoshop_order_item", $item, [
'id' => $item['id'],
]);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function addServices(Services $services)
'wpal',
'jigoshop.options',
'jigoshop.service.cart',
'jigoshop.service.order',
'jigoshop.messages'
]);
$services->setDetails('jigoshop.shipping.local_pickup', 'Jigoshop\Shipping\LocalPickup', [
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.1.2';
const VERSION = '2.1.3';
const WIDGET_CACHE = 'jigoshop_widget_cache';
const TERMS = 'jigoshop_term';

Expand Down
1 change: 1 addition & 0 deletions src/Jigoshop/Core/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ class Options
'category' => 'product-category',
'tag' => 'product-tag',
'verbose' => false,
'with_front' => true,
],
];
private $options = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Jigoshop/Core/Types/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getDefinition()
'hierarchical' => false, // Hierarchical causes a memory leak http://core.trac.wordpress.org/ticket/15459
'rewrite' => [
'slug' => $this->options->get('permalinks.product'),
'with_front' => true,
'with_front' => $this->options->get('permalinks.with_front'),
'feeds' => true,
'pages' => true,
],
Expand Down
2 changes: 1 addition & 1 deletion src/Jigoshop/Core/Types/ProductCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getDefinition()
'query_var' => true,
'rewrite' => [
'slug' => $this->options->get('permalinks.category'),
'with_front' => true,
'with_front' => $this->options->get('permalinks.with_front'),
'feeds' => false,
'pages' => true,
'ep_mask' => EP_ALL,
Expand Down
2 changes: 1 addition & 1 deletion src/Jigoshop/Core/Types/ProductTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getDefinition()
'query_var' => true,
'rewrite' => [
'slug' => $this->options->get('permalinks.tag'),
'with_front' => true,
'with_front' => $this->options->get('permalinks.with_front'),
'feeds' => false,
'pages' => true,
'ep_mask' => EP_ALL,
Expand Down
15 changes: 10 additions & 5 deletions src/Jigoshop/Shipping/FreeShipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
use Jigoshop\Core\Messages;
use Jigoshop\Core\Options;
use Jigoshop\Core\Types;
use Jigoshop\Entity\Coupon;
use Jigoshop\Entity\Order\Discount;
use Jigoshop\Entity\OrderInterface;
use Jigoshop\Helper\Country;
use Jigoshop\Helper\Scripts;
use Jigoshop\Service\CartServiceInterface;
use Jigoshop\Service\OrderServiceInterface;
use WPAL\Wordpress;

class FreeShipping implements Method
Expand All @@ -24,16 +24,19 @@ class FreeShipping implements Method
private $options;
/** @var CartServiceInterface */
private $cartService;
/** @var OrderServiceInterface */
private $orderService;
/** @var Messages */
private $messages;
/** @var array */
private $availability;

public function __construct(Wordpress $wp, Options $options, CartServiceInterface $cartService, Messages $messages)
public function __construct(Wordpress $wp, Options $options, CartServiceInterface $cartService, OrderServiceInterface $orderService, Messages $messages)
{
$this->wp = $wp;
$this->options = $options->get('shipping.'.self::NAME);
$this->cartService = $cartService;
$this->orderService = $orderService;
$this->messages = $messages;

$this->availability = [
Expand Down Expand Up @@ -96,11 +99,13 @@ public function isEnabled()
}, false);
} else {
// TODO: Get rid of this hack for customer fetching
$customer = unserialize($this->wp->getPostMeta($post->ID, 'customer', true));
$order = $this->orderService->findForPost($post);
$customer = $order->getCustomer();
}

return $this->options['enabled'] && ($freeShippingDiscount || ($order->getProductSubtotal() >= $this->options['minimum'] &&
($this->options['available_for'] === 'all' || in_array($customer->getShippingAddress()->getCountry(), $this->options['countries']))));
return $this->options['enabled'] && ($freeShippingDiscount || (
($order instanceof OrderInterface && $order->getProductSubtotal() >= $this->options['minimum']) &&
($this->options['available_for'] === 'all' || in_array($customer->getShippingAddress()->getCountry(), $this->options['countries']))));
}

/**
Expand Down
7 changes: 7 additions & 0 deletions templates/admin/permalinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @var $base string
* @var $productBase string
* @var $homeUrl string
* @var $front string
*/
?>
<table class="form-table">
Expand Down Expand Up @@ -37,6 +38,12 @@
<span class="description"><?php _e('Enter a custom base to use. A base <strong>must</strong> be set or WordPress will use default instead.', 'jigoshop'); ?></span>
</td>
</tr>
<tr>
<th><label><input name="product_permalink_with_front" type="checkbox" value="on" <?= Forms::checked($with_front, true); ?> /> <?php _e('With Front', 'jigoshop'); ?></label></th>
<td>
<span class=""><?= sprintf(__('Prepend product permalink with <code>%s</code>.', 'jigoshop'), preg_replace('$/%(.*)%/$', '', get_option('permalink_structure'))); ?></span>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
Expand Down
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 ComposerAutoloaderInit00cea331c1b2fd82a65e5889219bf42d::getLoader();
return ComposerAutoloaderInitf72775d2b5c252eb7e5b6e4b88ce2cbe::getLoader();
10 changes: 5 additions & 5 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 ComposerAutoloaderInit00cea331c1b2fd82a65e5889219bf42d
class ComposerAutoloaderInitf72775d2b5c252eb7e5b6e4b88ce2cbe
{
private static $loader;

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

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

$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
Expand All @@ -42,14 +42,14 @@ public static function getLoader()

$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire00cea331c1b2fd82a65e5889219bf42d($fileIdentifier, $file);
composerRequiref72775d2b5c252eb7e5b6e4b88ce2cbe($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequire00cea331c1b2fd82a65e5889219bf42d($fileIdentifier, $file)
function composerRequiref72775d2b5c252eb7e5b6e4b88ce2cbe($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
Expand Down
Loading

0 comments on commit 456c107

Please sign in to comment.