Skip to content

Commit

Permalink
Merge branch 'hotfix/2.5.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Oct 9, 2018
2 parents 8e586f4 + 925ee34 commit 60bc286
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 12 deletions.
2 changes: 1 addition & 1 deletion system/modules/isotope/dca/tl_nc_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* Palettes
*/
$GLOBALS['TL_DCA']['tl_nc_notification']['palettes']['iso_order_status_change'] = '{title_legend},title,type;{config_legend},iso_collectionTpl,iso_orderCollectionBy,iso_gallery,iso_document';
$GLOBALS['TL_DCA']['tl_nc_notification']['palettes']['iso_order_status_change'] = '{title_legend},title,type;{config_legend},iso_collectionTpl,iso_orderCollectionBy,iso_gallery,iso_document;{templates_legend:hide},templates';


/**
Expand Down
11 changes: 11 additions & 0 deletions system/modules/isotope/docs/CHANGELOG-2.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ Isotope eCommerce Changelog
===========================


Version 2.5.6-stable (2018-10-09)
---------------------------------

- Renamed session key to fix compatibility with Contao 4.6 (#1974)
- Fixed order of product actions configured in the module (#1950)
- Fixed member address being added to address book (#1862)
- Fixed images in PDFs in Contao 4 (#1980)
- Added support for templates in notification center
- Fixed empty sku being submitted to PayPal


Version 2.5.5-stable (2018-09-27)
---------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function generate()
$this->objForm->addFieldsFromFormGenerator(
$this->objModule->iso_order_conditions,
function ($strName, &$arrDca) {
$arrDca['value'] = $_SESSION['FORM_DATA'][$strName] ?: $arrDca['value'];
$arrDca['value'] = $_SESSION['CHECKOUT_DATA'][$strName] ?: $arrDca['value'];

return true;
}
Expand All @@ -84,7 +84,7 @@ function ($strName, &$arrDca) {
if ($this->objForm->isSubmitted()) {
$this->blnError = !$this->objForm->validate();

$_SESSION['FORM_DATA'] = is_array($_SESSION['FORM_DATA']) ? $_SESSION['FORM_DATA'] : array();
$_SESSION['CHECKOUT_DATA'] = is_array($_SESSION['CHECKOUT_DATA']) ? $_SESSION['CHECKOUT_DATA'] : array();
foreach (array_keys($this->objForm->getFormFields()) as $strField) {
if ($this->objForm->getWidget($strField) instanceof \uploadable) {
$arrFile = $_SESSION['FILES'][$strField];
Expand All @@ -93,7 +93,7 @@ function ($strName, &$arrDca) {
$varValue = $this->objForm->fetch($strField);
}

$_SESSION['FORM_DATA'][$strField] = $varValue;
$_SESSION['CHECKOUT_DATA'][$strField] = $varValue;
}

} else {
Expand Down Expand Up @@ -142,8 +142,8 @@ public function getNotificationTokens(IsotopeProductCollection $objCollection)
foreach ($this->objForm->getFormFields() as $strField => $arrConfig) {
$varValue = null;

if (isset($_SESSION['FORM_DATA'][$strField])) {
$varValue = $_SESSION['FORM_DATA'][$strField];
if (isset($_SESSION['CHECKOUT_DATA'][$strField])) {
$varValue = $_SESSION['CHECKOUT_DATA'][$strField];

if ('textarea' === $arrConfig['type']) {
$varValue = nl2br($varValue);
Expand Down
2 changes: 1 addition & 1 deletion system/modules/isotope/library/Isotope/Isotope.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Isotope extends \Controller
/**
* Isotope version
*/
const VERSION = '2.5.5';
const VERSION = '2.5.6';

/**
* True if the system has been initialized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,20 @@ protected function generateTemplate(IsotopeProductCollection $objCollection, arr

// URL decode image paths (see contao/core#6411)
// Make image paths absolute
$strBuffer = preg_replace_callback('@(src=")([^"]+)(")@', function ($args) {
$blnOverrideRoot = false;
$strBuffer = preg_replace_callback('@(src=")([^"]+)(")@', function ($args) use (&$blnOverrideRoot) {
if (preg_match('@^(http://|https://)@', $args[2])) {
return $args[1] . $args[2] . $args[3];
}

$blnOverrideRoot = true;
return $args[1] . TL_ROOT . '/' . rawurldecode($args[2]) . $args[3];
}, $strBuffer);

if ($blnOverrideRoot) {
$_SERVER['DOCUMENT_ROOT'] = TL_ROOT;
}

// Handle line breaks in preformatted text
$strBuffer = preg_replace_callback('@(<pre.*</pre>)@Us', 'nl2br_callback', $strBuffer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ public function createPayment(IsotopePurchasableCollection $order)
{
$items = [];
foreach ($order->getItems() as $item) {
$items[] = [
$row = [
'name' => strip_tags($item->name),
'sku' => $item->sku,
'price' => number_format($item->getPrice(), 2),
'currency' => $order->getCurrency(),
'quantity' => $item->quantity,
];

if ($item->sku) {
$row['sku'] = $item->sku;
}

$items[] = $row;
}

foreach ($order->getSurcharges() as $surcharge) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@ function (ProductActionInterface $action) use ($arrConfig) {
}
);

// Sort actions by order in module configuration
$buttonOrder = array_values($arrConfig['buttons']);
usort($actions, function (ProductActionInterface $a, ProductActionInterface $b) use ($buttonOrder) {
return array_search($a->getName(), $buttonOrder) - array_search($b->getName(), $buttonOrder);
});

if (\Input::post('FORM_SUBMIT') == $this->getFormId() && !$this->doNotSubmit) {
$handleButtons = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
* @property float $tax_free_total
* @property string $currency
* @property string $language
*
* @property int $nc_notification
* @property bool $iso_addToAddressbook
* @property array $iso_checkout_skippable
* @property array $email_data
*/
abstract class ProductCollection extends TypeAgent implements IsotopeProductCollection
{
Expand Down Expand Up @@ -134,6 +139,7 @@ public function __construct(\Database\Result $objResult = null)
*
* @throws \LogicException because ProductCollection cannot be cloned
*/
/** @noinspection MagicMethodsValidityInspection */
public function __clone()
{
throw new \LogicException(
Expand Down Expand Up @@ -1786,12 +1792,16 @@ protected function createPrivateAddresses()
throw new \UnderflowException('Product collection must be saved before creating unique addresses.');
}

$canSkip = deserialize($this->iso_checkout_skippable, true);
$objBillingAddress = $this->getBillingAddress();
$objShippingAddress = $this->getShippingAddress();

// Store address in address book
if ($this->iso_addToAddressbook && $this->member > 0) {
if (null !== $objBillingAddress && $objBillingAddress->ptable != \MemberModel::getTable()) {
if (null !== $objBillingAddress
&& $objBillingAddress->ptable != \MemberModel::getTable()
&& !in_array('billing_address', $canSkip, true)
) {
$objAddress = clone $objBillingAddress;
$objAddress->pid = $this->member;
$objAddress->tstamp = time();
Expand All @@ -1806,6 +1816,7 @@ protected function createPrivateAddresses()
&& null !== $objShippingAddress
&& $objBillingAddress->id != $objShippingAddress->id
&& $objShippingAddress->ptable != \MemberModel::getTable()
&& !in_array('shipping_address', $canSkip, true)
) {
$objAddress = clone $objShippingAddress;
$objAddress->pid = $this->member;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function checkout()
public function complete()
{
if ($this->isCheckoutComplete()) {
unset($_SESSION['FORM_DATA'], $_SESSION['FILES']);
unset($_SESSION['CHECKOUT_DATA'], $_SESSION['FILES']);

// Retain custom config ID
if (($objCart = Isotope::getCart()) !== null && $objCart->config_id != $this->config_id) {
Expand Down
3 changes: 3 additions & 0 deletions system/modules/isotope/library/Isotope/Module/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* @property array $iso_payment_modules
* @property array $iso_shipping_modules
* @property bool $iso_forward_review
* @property array $iso_notifications
* @property bool $iso_addToAddressbook
* @property array $iso_checkout_skippable
*/
class Checkout extends Module
Expand Down Expand Up @@ -216,6 +218,7 @@ protected function compile()
$objOrder->checkout_info = $this->getCheckoutInfo($arrSteps);
$objOrder->nc_notification = $this->iso_notifications;
$objOrder->iso_addToAddressbook = $this->iso_addToAddressbook;
$objOrder->iso_checkout_skippable = $this->iso_checkout_skippable;
$objOrder->email_data = $this->getNotificationTokensFromSteps($arrSteps, $objOrder);

// !HOOK: pre-process checkout
Expand Down

0 comments on commit 60bc286

Please sign in to comment.