Skip to content

Commit

Permalink
Merge pull request #95 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Release version 3.0.0
  • Loading branch information
Hlavtox committed Nov 20, 2023
2 parents d3c9c85 + 8d1852f commit 6f3845a
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .github/mktp-metadata.json
Expand Up @@ -5,6 +5,6 @@
"channel": "stable",
"type_upgrade": "updatemin",
"product_type": "module",
"compatible_from": "1.7.1.0",
"compatible_from": "1.7.5.0",
"rgpd_status": "1"
}
61 changes: 3 additions & 58 deletions .github/workflows/build-release.yml
Expand Up @@ -2,61 +2,6 @@ name: Build
on: [push, pull_request]

jobs:
deploy:
name: build dependencies & create artifact
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.0.0
- name: Install composer dependencies
run: composer install --no-dev -o
- name: Clean-up project
uses: PrestaShopCorp/github-action-clean-before-deploy@v1.0
- name: Prepare auto-index tool
run: |
composer global require prestashop/autoindex
- name: Generate index.php
run: |
~/.composer/vendor/bin/autoindex
- name: Create & upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ github.event.repository.name }}
path: ../
update_release_draft:
runs-on: ubuntu-latest
needs: [deploy]
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: ${{ github.event.repository.name }}
- id: release_info
uses: toolmantim/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare for Release
run: |
cd ${{ github.event.repository.name }}
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
- name: Clean existing assets
shell: bash
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'`
for asset in $assets
do
bin/hub api -X DELETE $asset
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to GitHub Release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release_info.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}/${{ github.event.repository.name }}.zip
asset_name: ${{ github.event.repository.name }}.zip
asset_content_type: application/zip
build-and-release-draft:
name: Build & Release draft
uses: PrestaShop/.github/.github/workflows/build-release.yml@master
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Expand Up @@ -58,7 +58,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ['1.7.1.2', '1.7.2.5', '1.7.3.4', '1.7.4.4', '1.7.5.1', '1.7.6', '1.7.7', '1.7.8', 'latest']
presta-versions: ['1.7.5.1', '1.7.6', '1.7.7', '1.7.8', 'latest']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -4,13 +4,29 @@

Display a shopping cart icon on your pages and the number of items it contains.

## Compatibility

PrestaShop: `1.7.5.0` or later

## Multistore compatibility

This module is compatible with the multistore :heavy_check_mark: <br/>
It can be configured differently from one store to another.<br/>
It can be configured quickly in the same way on all stores thanks to the all shops context or the group of shops.<br/>
It can be activated on one store and deactivated on another

## How to test

Link to specs : https://docs.prestashop-project.org/functional-documentation/functional-documentation/ux-ui/back-office/improve/modules/shopping-cart-ps_shoppingcart

you can have all the scenarios related to this module :

Link to scenarios : https://build.prestashop-project.org/test-scenarios/scenarios/modules/ps-shoppingcart.html



Enable/disable Ajax cart option. Check on FO that when disabled, the page needs to be refreshed in order to see the product in cart.

## Reporting issues

You can report issues with this module in the main PrestaShop repository. [Click here to report an issue][report-issue].
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": ">=5.4"
"php": ">=5.6"
},
"require-dev": {
"prestashop/php-dev-tools": "~3.0"
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_shoppingcart</name>
<displayName><![CDATA[Shopping cart]]></displayName>
<version><![CDATA[2.0.7]]></version>
<version><![CDATA[3.0.0]]></version>
<description><![CDATA[Adds a block containing the customer&#039;s shopping cart.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
Expand Down
5 changes: 2 additions & 3 deletions controllers/front/ajax.php
Expand Up @@ -35,9 +35,8 @@ public function initContent()

$modal = null;

if ($this->module instanceof Ps_Shoppingcart && Tools::getValue('action') === 'add-to-cart') {
if (Tools::getValue('action') === 'add-to-cart') {
$modal = $this->module->renderModal(
$this->context->cart,
(int) Tools::getValue('id_product'),
(int) Tools::getValue('id_product_attribute'),
(int) Tools::getValue('id_customization')
Expand All @@ -47,7 +46,7 @@ public function initContent()
ob_end_clean();
header('Content-Type: application/json');
exit(json_encode([
'preview' => $this->module instanceof Ps_Shoppingcart ? $this->module->renderWidget(null, ['cart' => $this->context->cart]) : '',
'preview' => $this->module->renderWidget(null, []),
'modal' => $modal,
]));
}
Expand Down
39 changes: 29 additions & 10 deletions ps_shoppingcart.php
Expand Up @@ -18,7 +18,7 @@
* International Registered Trademark & Property of PrestaShop SA
*/

use PrestaShop\PrestaShop\Adapter\Cart\CartPresenter;
use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter;

if (!defined('_PS_VERSION_')) {
exit;
Expand All @@ -37,7 +37,7 @@ public function __construct()
{
$this->name = 'ps_shoppingcart';
$this->tab = 'front_office_features';
$this->version = '2.0.7';
$this->version = '3.0.0';
$this->author = 'PrestaShop';
$this->need_instance = 0;

Expand All @@ -46,7 +46,7 @@ public function __construct()

$this->displayName = $this->trans('Shopping cart', [], 'Modules.Shoppingcart.Admin');
$this->description = $this->trans('Display a shopping cart icon on your pages and the number of items it contains.', [], 'Modules.Shoppingcart.Admin');
$this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_];
$this->ps_versions_compliancy = ['min' => '1.7.5.0', 'max' => _PS_VERSION_];
$this->controllers = ['ajax'];
}

Expand Down Expand Up @@ -90,15 +90,35 @@ private function getCartSummaryURL()
*/
public function getWidgetVariables($hookName, array $params)
{
$cart_url = $this->getCartSummaryURL();

return [
'cart' => (new CartPresenter())->present(isset($params['cart']) ? $params['cart'] : $this->context->cart),
'cart' => $this->getPresentedCart(),
'refresh_url' => $this->context->link->getModuleLink('ps_shoppingcart', 'ajax', [], null, null, null, true),
'cart_url' => $cart_url,
'cart_url' => $this->getCartSummaryURL(),
];
}

/**
* Provides an already presented object from the context if set.
* If not, runs the presenter.
*
* @return array presented cart
*/
private function getPresentedCart()
{
/*
* We will use the already presented cart in the first place. It should be already in the template.
* Check FrontController::assignGeneralPurposeVariables for more information.
*
* If it's not, we will present the cart ourselves. There will always be a cart object
* assigned in FrontController::init.
*/
if (!empty($this->context->smarty->getTemplateVars('cart'))) {
return $this->context->smarty->getTemplateVars('cart');
} else {
return (new CartPresenter())->present($this->context->cart);
}
}

/**
* @param string|null $hookName
* @param array<string,mixed> $params
Expand All @@ -117,7 +137,6 @@ public function renderWidget($hookName, array $params)
}

/**
* @param Cart $cart
* @param int $id_product
* @param int $id_product_attribute
* @param int $id_customization
Expand All @@ -126,9 +145,9 @@ public function renderWidget($hookName, array $params)
*
* @throws Exception
*/
public function renderModal(Cart $cart, $id_product, $id_product_attribute, $id_customization)
public function renderModal($id_product, $id_product_attribute, $id_customization)
{
$data = (new CartPresenter())->present($cart);
$data = $this->getPresentedCart();
$product = null;
foreach ($data['products'] as $p) {
if ((int) $p['id_product'] == $id_product &&
Expand Down
6 changes: 0 additions & 6 deletions tests/phpstan/phpstan-1.7.1.0.neon

This file was deleted.

6 changes: 0 additions & 6 deletions tests/phpstan/phpstan-1.7.1.2.neon

This file was deleted.

6 changes: 0 additions & 6 deletions tests/phpstan/phpstan-1.7.2.5.neon

This file was deleted.

6 changes: 0 additions & 6 deletions tests/phpstan/phpstan-1.7.3.4.neon

This file was deleted.

2 changes: 0 additions & 2 deletions tests/phpstan/phpstan-1.7.4.4.neon

This file was deleted.

3 changes: 3 additions & 0 deletions tests/phpstan/phpstan.neon
Expand Up @@ -8,4 +8,7 @@ parameters:
- ../../controllers/
- ../../translations/
- ../../upgrade/
ignoreErrors:
- '#Call to an undefined method Module::renderModal\(\).#'
- '#Call to an undefined method Module::renderWidget\(\).#'
level: 5

0 comments on commit 6f3845a

Please sign in to comment.