Skip to content

Commit

Permalink
Merge pull request #28 from logeecom/3.0-3.4
Browse files Browse the repository at this point in the history
Release version 0.1.7
  • Loading branch information
pkrstojevic-logeecom authored Jan 26, 2021
2 parents 110acdc + 6ba2292 commit d8a8d3f
Show file tree
Hide file tree
Showing 20 changed files with 706 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ The payment methods are disabled by default in your account so you firstly need
6. **Check if there is any information in the logfile `Toolbox` » `Show logs`**

# Release notes
*0.1.7*
- Optimization: Restock product quantity, recalculate delivery status and reset article status when order is canceled during the checkout due to failed payment.

*0.1.6*
- Bugfix: Fix issues with mollie components when it is only payment method.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
'mollie.payment.integration.event.notification.order_cancel_error.title' => 'Synchronisatie van winkelwijziging mislukt',
'mollie.payment.integration.event.notification.order_cancel_error.description' => 'De bestelling van Mollie kan niet worden geannuleerd. Reactie Mollie API: {api_message}',

'mollie.payment.integration.event.notification.order_cancel.title' => 'Order cancel event detected',
'mollie.payment.integration.event.notification.order_cancel.description' => 'Order cancel is not supported, so this change is not synchronized to the Mollie',

'mollie.payment.integration.event.notification.billing_address_change_error.title' => 'Synchronisatie van winkelwijziging mislukt',
'mollie.payment.integration.event.notification.billing_address_change_error.description' => 'Het factuuradres van de Mollie-bestelling kan niet worden bijgewerkt. Reactie Mollie API: {api_message}',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
'mollie.payment.integration.event.notification.order_cancel_error.title' => 'Shop change synchronization failed',
'mollie.payment.integration.event.notification.order_cancel_error.description' => 'Failed to cancel Mollie order. Mollie api response {api_message}',

'mollie.payment.integration.event.notification.order_cancel.title' => 'Order cancel event detected',
'mollie.payment.integration.event.notification.order_cancel.description' => 'Order cancel is not supported, so this change is not synchronized to the Mollie',

'mollie.payment.integration.event.notification.billing_address_change_error.title' => 'Shop change synchronization failed',
'mollie.payment.integration.event.notification.billing_address_change_error.description' => 'Failed to update billing address on Mollie order. Mollie api response {api_message}',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
'mollie.payment.integration.event.notification.order_cancel_error.title' => 'La synchronisation du changement de magasin a échoué',
'mollie.payment.integration.event.notification.order_cancel_error.description' => "Échec de l'annulation de la commande Mollie. Réponse de l'api Mollie {api_message}",

'mollie.payment.integration.event.notification.order_cancel.title' => 'Order cancel event detected',
'mollie.payment.integration.event.notification.order_cancel.description' => 'Order cancel is not supported, so this change is not synchronized to the Mollie',

'mollie.payment.integration.event.notification.billing_address_change_error.title' => 'La synchronisation du changement de magasin a échoué',
'mollie.payment.integration.event.notification.billing_address_change_error.description' => "Échec de la mise à jour de l'adresse de facturation de la commande Mollie. Réponse de l'api Mollie {api_message}",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
'mollie.payment.integration.event.notification.order_cancel_error.title' => 'Synchronisieren von Shop-Änderungen fehlgeschlagen',
'mollie.payment.integration.event.notification.order_cancel_error.description' => 'Mollie-Bestellung konnte nicht storniert werden. Antwort Mollie-API {api_message}',

'mollie.payment.integration.event.notification.order_cancel.title' => 'Order cancel event detected',
'mollie.payment.integration.event.notification.order_cancel.description' => 'Order cancel is not supported, so this change is not synchronized to the Mollie',

'mollie.payment.integration.event.notification.billing_address_change_error.title' => 'Synchronisieren von Shop-Änderungen fehlgeschlagen',
'mollie.payment.integration.event.notification.billing_address_change_error.description' => 'Aktualisieren der Rechnungsadresse für die Mollie-Bestellung fehlgeschlagen. Antwort Mollie-API {api_message}',

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php


namespace Mollie\Gambio\Entity\Repository;

/**
* Class GambioOrderProductRepository
*
* @package Mollie\Gambio\Entity\Repository
*/
class GambioOrderProductRepository extends GambioBaseRepository
{
/**
* Returns list of orders products filtered by order id with following details
* - orders_products_id
* - products_id
* - products_quantity
* - products_properties_combis_id
* - products_attributes_filename
* - date_purchased
*
* @param string $orderId
*
* @return array
*/
public function getOrderProductsWithAttributes($orderId)
{
return $this->queryBuilder->query($this->getOrderProductsWithDetailsQuery($orderId))->result_array();
}

/**
* @inheritDoc
* @return string
*/
protected function _getTableName()
{
return TABLE_ORDERS_PRODUCTS;
}

/**
* @inheritDoc
* @return string
*/
protected function _getIdentifierKey()
{
return 'orders_products_id';
}

/**
* @param string $orderId
*
* @return string
*/
private function getOrderProductsWithDetailsQuery($orderId)
{
return 'SELECT DISTINCT
op.orders_products_id,
op.products_id,
op.products_quantity,
opp.products_properties_combis_id,
pad.products_attributes_filename,
o.date_purchased
FROM ' . TABLE_ORDERS_PRODUCTS . ' op
LEFT JOIN ' . TABLE_ORDERS . ' o
ON op.orders_id = o.orders_id
LEFT JOIN orders_products_properties opp
ON opp.orders_products_id = op.orders_products_id
LEFT JOIN ' . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . ' `opa`
ON opa.orders_products_id = op.orders_products_id
LEFT JOIN ' . TABLE_PRODUCTS_ATTRIBUTES . ' pa
ON op.products_id = pa.products_id
AND opa.options_id = pa.options_id
AND opa.options_values_id = pa.options_values_id
LEFT JOIN ' . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
ON pa.products_attributes_id=pad.products_attributes_id
WHERE
op.orders_id = '" . xtc_db_input($orderId) . "'";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php


namespace Mollie\Gambio\Entity\Repository;

/**
* Class GambioProductPropertiesRepository
*
* @package Mollie\Gambio\Entity\Repository
*/
class GambioProductAttributesRepository extends GambioBaseRepository
{
/**
* Returns product attributes list filtered by order id and order product id in format:
* - products_options
* - products_options_values
*
* @param int $orderId
* @param int $ordersProductsId
*
* @return array
*/
public function getOrdersAttributes($orderId, $ordersProductsId)
{
return $this->queryBuilder
->select('products_options, products_options_values')
->where('orders_id', $orderId, true)
->where('orders_products_id', $ordersProductsId, true)
->get($this->_getTableName())
->result('array');
}

/**
* @param int $productsId
* @param string $productsOptions
* @param string $productsOptionsValues
*
* @return mixed
*/
public function getProductAttributesId($productsId, $productsOptions, $productsOptionsValues)
{
$query = "SELECT pa.products_attributes_id
FROM products_options_values pov,
products_options po,
products_attributes pa
WHERE po.products_options_name = '" . addslashes($productsOptions) . "'
AND po.products_options_id = pa.options_id
AND pov.products_options_values_id = pa.options_values_id
AND pov.products_options_values_name = '" . addslashes($productsOptionsValues) . "'
AND pa.products_id = '" . $productsId . "'
LIMIT 1";

$result = $this->queryBuilder->query($query)->result_array();

return !empty($result[0]['products_attributes_id']) ? $result[0]['products_attributes_id'] : null;
}

/**
* Increases attributes stock
*
* @param int $productAttributesId
* @param int $quantity
*/
public function increaseAttributesStock($productAttributesId, $quantity)
{
$query = 'UPDATE products_attributes
SET attributes_stock = attributes_stock + ' . (int)$quantity . "
WHERE products_attributes_id = '" . (int)$productAttributesId . "'";

$this->queryBuilder->query($query);
}

/**
* @inheritDoc
*/
protected function _getTableName()
{
return TABLE_ORDERS_PRODUCTS_ATTRIBUTES;
}

/**
* @inheritDoc
*/
protected function _getIdentifierKey()
{
return 'products_attributes_id';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php


namespace Mollie\Gambio\Entity\Repository;

/**
* Class ProductPropertiesCombisRepository
*
* @package Mollie\Gambio\Entity\Repository
*/
class GambioProductPropertiesCombisRepository extends GambioBaseRepository
{

/**
* Returns row count specified by productId
*
* @param int $productId
*
* @return int
*/
public function countByProductId($productId)
{
return $this->queryBuilder
->select('products_properties_combis_id')
->from($this->_getTableName())
->where('products_id', $productId)
->get()
->num_rows();
}

/**
* Increases combi quantity by productId
*
* @param int $productId
* @param int $productsPropertiesCombisId
* @param int $quantity
*/
public function increaseCombiQuantity($productId, $productsPropertiesCombisId, $quantity)
{
$this->queryBuilder->query($this->getUpdateProductPropertiesCombiesQuery($productId, $productsPropertiesCombisId, $quantity));
}

/**
* @inheritDoc
*/
protected function _getTableName()
{
return 'products_properties_combis';
}

/**
* @inheritDoc
*/
protected function _getIdentifierKey()
{
return 'products_properties_combis_values_id';
}

/**
* @param int $productId
* @param int $productsPropertiesCombisId
* @param int $quantity
*
* @return string
*/
private function getUpdateProductPropertiesCombiesQuery($productId, $productsPropertiesCombisId, $quantity)
{
return 'UPDATE ' . $this->_getTableName() . '
SET combi_quantity = combi_quantity + ' . (int)$quantity . "
WHERE products_properties_combis_id = '" . (int)$productsPropertiesCombisId . "'
AND products_id = '" . (int)$productId . "'";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,49 @@
*/
class GambioProductRepository extends GambioBaseRepository
{
const INCREASE_OPERATOR = '+';
const DECREASE_OPERATOR = '-';
const PRODUCT_QUANTITY_COLUMN = 'products_quantity';
const ORDERED_QUANTITY_COLUMN = 'products_ordered';


/**
* Increases products stock by given value for specific product
*
* @param int $productId
* @param int $quantity
*/
public function increaseProductQuantity($productId, $quantity)
{
$this->updateQuantity($productId, $quantity, self::PRODUCT_QUANTITY_COLUMN, self::INCREASE_OPERATOR);
}

/**
* Decreases ordered quantity by given value for specific product
*
* @param int $productId
* @param int $quantity
*/
public function decreaseProductOrderedQuantity($productId, $quantity)
{
$this->updateQuantity($productId, $quantity, self::ORDERED_QUANTITY_COLUMN, self::DECREASE_OPERATOR);
}

/**
* @param int $productId
* @param int $quantity
* @param string $columnName
* @param string $operator
*/
private function updateQuantity($productId, $quantity, $columnName, $operator)
{
$query = 'UPDATE ' .$this->_getTableName() . '
SET ' . $columnName . ' = ' . $columnName . $operator . (int)$quantity . "
WHERE products_id = '" . (int)$productId . "'";

$this->queryBuilder->query($query);
}

/**
* @return string
*/
Expand All @@ -25,6 +68,4 @@ protected function _getIdentifierKey()
{
return 'products_id';
}


}
Loading

0 comments on commit d8a8d3f

Please sign in to comment.