update
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Przelewy24
|
||||
* @copyright Przelewy24
|
||||
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html
|
||||
*
|
||||
*/
|
||||
* @author Przelewy24
|
||||
* @copyright Przelewy24
|
||||
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!class_exists('Przelewy24Product', false)) {
|
||||
/**
|
||||
@@ -19,7 +21,7 @@ if (!class_exists('Przelewy24Product', false)) {
|
||||
*/
|
||||
private $translations;
|
||||
|
||||
public function __construct(array $translations = array())
|
||||
public function __construct(array $translations = [])
|
||||
{
|
||||
$this->setTranslations($translations);
|
||||
}
|
||||
@@ -29,35 +31,35 @@ if (!class_exists('Przelewy24Product', false)) {
|
||||
*
|
||||
* Read more: /docs/przelewy24product.md.
|
||||
*/
|
||||
public function prepareCartItems($amount, array $items = array(), $shipping = 0)
|
||||
public function prepareCartItems($amount, array $items = [], $shipping = 0)
|
||||
{
|
||||
$cartItems = array();
|
||||
$cartItems = [];
|
||||
|
||||
if (empty($items)) {
|
||||
return $cartItems;
|
||||
}
|
||||
|
||||
$amount = (int)$amount;
|
||||
$shipping = (int)$shipping;
|
||||
$amount = (int) $amount;
|
||||
$shipping = (int) $shipping;
|
||||
|
||||
$number = 0;
|
||||
$sumProductsPrice = 0;
|
||||
$joinName = '';
|
||||
foreach ($items as $item) {
|
||||
$number++;
|
||||
++$number;
|
||||
|
||||
$cartItems['p24_name_' . $number] = Tools::substr(strip_tags($item['name']), 0, 127);
|
||||
$cartItems['p24_description_' . $number] = Tools::substr(strip_tags($item['description']), 0, 127);
|
||||
$cartItems['p24_quantity_' . $number] = (int)$item['quantity'];
|
||||
$cartItems['p24_price_' . $number] = (int)$item['price'];
|
||||
$cartItems['p24_number_' . $number] = (int)$item['number'];
|
||||
$cartItems['p24_quantity_' . $number] = (int) $item['quantity'];
|
||||
$cartItems['p24_price_' . $number] = (int) $item['price'];
|
||||
$cartItems['p24_number_' . $number] = (int) $item['number'];
|
||||
|
||||
$joinName .= strip_tags($item['name']) . ', ';
|
||||
$sumProductsPrice += ((int)$item['quantity'] * (int)$item['price']);
|
||||
$sumProductsPrice += ((int) $item['quantity'] * (int) $item['price']);
|
||||
}
|
||||
|
||||
if ($amount > $shipping + $sumProductsPrice) {
|
||||
$number++;
|
||||
++$number;
|
||||
|
||||
$cartItems['p24_name_' . $number] = $this->translations['virtual_product_name'];
|
||||
$cartItems['p24_description_' . $number] = '';
|
||||
@@ -65,7 +67,7 @@ if (!class_exists('Przelewy24Product', false)) {
|
||||
$cartItems['p24_price_' . $number] = $amount - ($shipping + $sumProductsPrice);
|
||||
$cartItems['p24_number_' . $number] = 0;
|
||||
} elseif ($amount < $shipping + $sumProductsPrice) {
|
||||
$cartItems = array();
|
||||
$cartItems = [];
|
||||
$number = 1;
|
||||
$joinName = $this->translations['cart_as_product'] . ' [' . trim($joinName, ', ') . ']';
|
||||
|
||||
@@ -84,7 +86,7 @@ if (!class_exists('Przelewy24Product', false)) {
|
||||
*
|
||||
* @param array $translations
|
||||
*/
|
||||
public function setTranslations(array $translations = array())
|
||||
public function setTranslations(array $translations = [])
|
||||
{
|
||||
$this->translations = $translations;
|
||||
// set default values
|
||||
|
||||
Reference in New Issue
Block a user