Skip to content

Commit

Permalink
Merge branch 'silvershop:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
MLindenhofer authored Oct 4, 2023
2 parents 909c005 + 6e0c303 commit f7afd7c
Show file tree
Hide file tree
Showing 108 changed files with 631 additions and 1,186 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
docs/ export-ignore
docs_user/ export-ignore
.travis.yml export-ignore
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
ci:
name: CI
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
with:
composer_require_extra:
phpunit/phpunit:^9.5
silverstripe/silverstripe-omnipay:dev-master
php-http/discovery:^1.18.1
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This module only moves forward as we each build the features we need. We love pu
### Here is a quick list of ways you can contribute:

* __Test the latest code__. Install it and try it out.
* __Code new features and bug fixes__. Make sure to check our [Trello board](https://trello.com/b/85ZyINqI/silvershop-development-planning) for upcoming features. Submit github pull requests. Don't forget to write PHPUnit tests that ensure your code runs. All pull requests are automatically tested [via TravisCI](https://travis-ci.org/silvershop/silvershop-core/pull_requests).
* __Code new features and bug fixes__. Make sure to check our [Trello board](https://trello.com/b/85ZyINqI/silvershop-development-planning) for upcoming features. Submit github pull requests. Don't forget to write PHPUnit tests that ensure your code runs.
* __Submit issues and ideas__. These can be bugs, or ideas. Be descriptive and detailed. Its better to discuss and design ideas before writing code. Please first check the [list of existing issues](https://github.com/silvershop/silvershop-core/issues) to make sure an identical one doesn't exist already.
* __Write documentation__. Both the developer and user documentation can have pieces missing. Documentation is stored in the repository under `/shop/docs`, and `/shop/docs_user`. Documentation gets displayed at http://docs.ss-shop.org
* __Provide translations__. This will allow people speaking other languages to use the shop module.
Expand Down
607 changes: 0 additions & 607 deletions ChangeLog.md

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

The SilverShop module aims to provide developers with a framework for building, and customising ecommerce-based projects.
It includes facilities for customers to browse products and place orders, and for administrators to manage products and orders.
We've put a strong focus on testing, and thanks to TravisCI, you can see the [build status](https://travis-ci.org/silvershop/silvershop-core) of this project, running on MySQL, SQLite, Postgres, as well as a few different versions of PHP.
We've put a strong focus on testing. You can see the [![build status](https://github.com/silvershop/silvershop-core/actions/workflows/ci.yml/badge.svg)](https://github.com/silvershop/silvershop-core/actions/workflows/ci.yml) of this project, running on MySQL, SQLite, Postgres, as well as a few different versions of PHP.

[![Latest Stable Version](https://poser.pugx.org/silvershop/core/v/stable.png)](https://packagist.org/packages/silvershop/core)
[![Latest Unstable Version](https://poser.pugx.org/silvershop/core/v/unstable.png)](https://packagist.org/packages/silvershop/core)
[![Build Status](https://travis-ci.org/silvershop/silvershop-core.svg?branch=master)](http://travis-ci.org/silvershop/silvershop-core)
[![CI](https://github.com/silvershop/silvershop-core/actions/workflows/ci.yml/badge.svg)](https://github.com/silvershop/silvershop-core/actions/workflows/ci.yml)
[![Code Coverage](https://scrutinizer-ci.com/g/silvershop/silvershop-core/badges/coverage.png?s=1abe84b468ef3d96646a0546954adba8131d6459)](https://scrutinizer-ci.com/g/silvershop/silvershop-core/)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/silvershop/silvershop-core/badges/quality-score.png?s=d60753d6cca3817e80aca3dbb79eb5bd4140c981)](https://scrutinizer-ci.com/g/silvershop/silvershop-core/)
[![Total Downloads](https://poser.pugx.org/silvershop/core/downloads.png)](https://packagist.org/packages/silvershop/core)
Expand Down
41 changes: 41 additions & 0 deletions client/dist/javascript/CheckoutPage.nojquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Addressbook checkout component
* This handles a dropdown or radio buttons containing existing addresses or payment methods,
* with one of the options being "create a new ____". When that last option is selected, the
* other fields need to be shown, otherwise they need to be hidden.
*/
function onExistingValueChange() {
let existingValues = document.querySelectorAll('.hasExistingValues');
if(!existingValues) return;

existingValues.forEach(function (container, idx) {
let toggle = document.querySelector('.existingValues select, .existingValues input:checked');

// visible if the value is not an ID (numeric)
let toggleState = Number.isNaN(parseInt(toggle.value));
let toggleFields = container.querySelectorAll(".field:not(.existingValues)");

// animate the fields - hide or show
if (toggleFields && toggleFields.length > 0) {
toggleFields.forEach(field => {
field.style.display = toggleState ? '' : 'none';
})
}

// clear them out
toggleFields.forEach(field => {
field.querySelectorAll('input, select, textarea').forEach(f => {
f.value = '';
f.disabled = toggleState ? '' : 'disabled';
});
});
});
}

let selectors = document.querySelectorAll('.existingValues select');
if(selectors) selectors.forEach(selector => selector.addEventListener('change', onExistingValueChange));

let inputs = document.querySelectorAll('.existingValues input[type=radio]')
if(inputs) inputs.forEach(input => input.addEventListener('click', onExistingValueChange));

onExistingValueChange(); // handle initial state
28 changes: 12 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
}
],
"require": {
"silverstripe/cms": "^4",
"silverstripe/asset-admin": "*",
"silverstripe/silverstripe-omnipay": "^3@dev",
"silvershop/silverstripe-listsorter": "^3@dev",
"silvershop/silverstripe-sqlquerylist": "^2@dev",
"symbiote/silverstripe-gridfieldextensions": "^3.2"
"silverstripe/cms": "^5",
"silverstripe/silverstripe-omnipay": "^3@dev | dev-main#8f277fa5ef513ded38e55ed3c56778feada26174",
"silvershop/silverstripe-listsorter": "^3",
"silvershop/silverstripe-sqlquerylist": "^3",
"symbiote/silverstripe-gridfieldextensions": "^4"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"guzzle/plugin-mock": "^3.1",
"omnipay/dummy": "^2.1",
"omnipay/paymentexpress": "^2.1"
"phpunit/phpunit": "^9.5",
"php-http/guzzle7-adapter": "^1",
"omnipay/dummy": "dev-master",
"omnipay/paymentexpress": "dev-master",
"squizlabs/php_codesniffer": "^3.7.2"
},
"replace": {
"burnbright/silverstripe-shop": "1.*"
Expand All @@ -46,16 +46,12 @@
"suggest": {
"bummzack/silverstripe-omnipay-ui": "Adds UI Components to manage payments in the SilverStripe CMS.",
"silvershop/discounts": "Create coupons and generic discounts to be applied at checkout.",
"silvershop/shipping": "Provide various shipping methods.",
"silvershop/coloredvariations": "Select colours for variations",
"burnbright/silverstripe-shop-geocoding": "Geocoding support for addresses and visitors.",
"burnbright/silverstripe-shop-googleanalytics": "Records shop sales sales in google analytics.",
"markguinn/silverstripe-shop-ajax": "Basic ajax behaviours for add to cart, etc"
"silvershop/shipping": "Provide various shipping methods."
},
"extra": {
"snapshot": "https://raw.github.com/silvershop/silvershop-core/gh-pages/assets/screenshots/shipping%20estimate%20form.png",
"branch-alias": {
"dev-master": "3.x-dev"
"dev-main": "4.x-dev"
},
"expose": [
"client/dist"
Expand Down
2 changes: 1 addition & 1 deletion docs/en/02_Customisation/Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This module only moves forward as we each build the features we need. We love pu
### Here is a quick list of ways you can contribute:

* __Test the latest code__. Find out what branch is currently being worked on (usually 'master'). Install it and try it out.
* __Code new features and bug fixes__. Submit github pull requests. Don't forget to write PHPUnit tests that ensure your code runs. All pull requests are automatically tested [via TravisCI](https://travis-ci.org/burnbright/silverstripe-shop/pull_requests).
* __Code new features and bug fixes__. Submit github pull requests. Don't forget to write PHPUnit tests that ensure your code runs.
* __Submit issues and ideas__. These can be bugs, or ideas. Be descriptive and detailed. Its better to discuss and design ideas before writing code. Please first check the [list of existing issues](https://github.com/burnbright/silverstripe-shop/issues) to make sure an identical one doesn't exist already.
* __Write documentation__. Both the developer and user documentation can have pieces missing. Documentation is stored in the repository under `/shop/docs`, and `/shop/docs_user`. Documentation gets displayed at http://docs.ss-shop.org
* __Provide translations__. This will allow people speaking other languages to use the shop module: https://www.transifex.com/silvershop/silverstripe-shop/
Expand Down
8 changes: 3 additions & 5 deletions docs/en/02_Customisation/Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ Testing is highly important for maintaining a quality product.

We insist that the shop module contains a suite of unit tests that are updated with any changes to the code. Sub-Modules should also have their own test suites.
See the [framework testing documentation](http://docs.silverstripe.org/en/developer_guides/testing/) for setup information etc.
See also: [https://phpunit.de/manual/3.7/en/](https://phpunit.de/manual/3.7/en/)
See also: [https://docs.phpunit.de/en/9.6/](https://docs.phpunit.de/en/9.6/)

To run all shop tests visit `yoursite/dev/tests/module/shop`. If you intend on doing lots of development, it might be a good idea to run tests from the command line.

**Note:** Be aware that your website's configuration may affect your test results. The tests should set configuration correctly, but sometimes configuration options get missed.

Every change to this module is [tested using the Travis Continuous Integration service](https://travis-ci.org/burnbright/silverstripe-shop).

Current status: [![Build Status](https://travis-ci.org/silvershop/silvershop-core.svg?branch=master)](http://travis-ci.org/silvershop/silvershop-core)
Every change to this module is [![tested using a Continuous Integration service](https://github.com/silvershop/silvershop-core/actions/workflows/ci.yml/badge.svg)](https://github.com/silvershop/silvershop-core/actions/workflows/ci.yml).

### Writing Tests

Expand All @@ -23,4 +21,4 @@ The products created by the shop.yml file are all in draft form (unpublished). Y
As features/sites are being developed, they should be tested. In a nutshell, be sure to test the following main functionality:

* Adding/removing items from cart
* Placing an order. Follow the process end-to-end.
* Placing an order. Follow the process end-to-end.
15 changes: 12 additions & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>

<file>src</file>
<file>tests</file>

<!-- base rules are PSR-2 -->
<rule ref="PSR2" >
<!-- Current exclusions -->
Expand All @@ -18,17 +21,23 @@
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="PEAR.Functions.ValidDefaultValue.NotAtEnd" />
</rule>
<rule phpcbf-only="true" ref="Squiz.Strings.ConcatenationSpacing">
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="1" />
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>

<!-- use short array syntax (less thirdparty) -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax">
<exclude-pattern>/thirdparty/*</exclude-pattern>
</rule>

<!-- include php files only -->
<arg name="extensions" value="php,lib,inc,php5"/>

<!-- PHP-PEG generated file not intended for human consumption -->
<exclude-pattern>*/Fixtures/*</exclude-pattern>
<exclude-pattern>*/SSTemplateParser.php$</exclude-pattern>
<exclude-pattern>*/_fakewebroot/*</exclude-pattern>
<exclude-pattern>*/fixtures/*</exclude-pattern>
</ruleset>

24 changes: 13 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory suffix=".php">tests/php/</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Default">
<directory>tests/php</directory>
<directory>tests/php</directory>
</testsuite>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
<exclude>
<directory suffix=".php">tests/php/</directory>
</exclude>
</whitelist>
</filter>
</testsuites>
</phpunit>
4 changes: 2 additions & 2 deletions src/Admin/OrdersAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class OrdersAdmin extends ModelAdmin
OrderStatusLog::class
];

private static $model_importers = array();
private static $model_importers = [];

/**
* Restrict list to non-hidden statuses
Expand All @@ -42,7 +42,7 @@ public function getList()

if ($this->modelClass == Order::class) {
// Exclude hidden statuses
$list = $list->exclude('Status', Order::config()->hidden_status);
$list = $list->exclude('Status', Order::config()->hidden_status);
$this->extend('updateList', $list);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Admin/ProductBulkLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function processRecord($record, $columnMap, &$results, $preview = false)
}

// set image, based on filename
public function imageByFilename(&$obj, $val, $record)
public function imageByFilename(&$obj, $val)
{
$filename = trim(strtolower(Convert::raw2sql($val)));
$filenamedashes = str_replace(' ', '-', $filename);
Expand All @@ -165,7 +165,7 @@ public function imageByFilename(&$obj, $val, $record)
}

// find product group parent (ie Cateogry)
public function setParent(&$obj, $val, $record)
public function setParent(&$obj, $val)
{
$title = strtolower(Convert::raw2sql($val));
if ($title) {
Expand Down Expand Up @@ -281,15 +281,15 @@ public function variationRow(&$obj, $val, $record)
$variation->ProductID = $obj->ID; //link to product
$variation->write();
}
$varcols = array(
$varcols = [
'->processVariation',
'->processVariation1',
'->processVariation2',
'->processVariation3',
'->processVariation4',
'->processVariation5',
'->processVariation6',
);
];
foreach ($varcols as $col) {
if (isset($record[$col])) {
$parts = explode(':', $record[$col]);
Expand Down
8 changes: 4 additions & 4 deletions src/Cart/OrderTotalCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OrderTotalCalculator
*/
protected $order;

function __construct(Order $order)
public function __construct(Order $order)
{
$this->order = $order;
}
Expand All @@ -45,19 +45,19 @@ function __construct(Order $order)
* @throws Exception
* @throws \Psr\Container\NotFoundExceptionInterface
*/
function calculate()
public function calculate()
{
$runningtotal = $this->order->SubTotal();
$sort = 1;
$existingmodifiers = $this->order->Modifiers();

$modifierclasses = Order::config()->modifiers;

//check if modifiers are even in use
if (!is_array($modifierclasses) || empty($modifierclasses)) {
return $runningtotal;
}

$modifierclasses = array_unique($modifierclasses);

if (DB::get_conn()->supportsTransactions()) {
Expand Down
6 changes: 3 additions & 3 deletions src/Cart/ShoppingCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ private function findOrMakeItem(Buyable $buyable, $quantity = 1, $filter = [])
*
* @return OrderItem the item requested or null
*/
public function get(Buyable $buyable, $customfilter = array())
public function get(Buyable $buyable, $customfilter = [])
{
$order = $this->current();
if (!$buyable || !$order) {
Expand All @@ -377,9 +377,9 @@ public function get(Buyable $buyable, $customfilter = array())

$buyable = $this->getCorrectBuyable($buyable);

$filter = array(
$filter = [
'OrderID' => $order->ID,
);
];

$itemclass = Config::inst()->get(get_class($buyable), 'order_item');
$relationship = Config::inst()->get($itemclass, 'buyable_relationship');
Expand Down
Loading

0 comments on commit f7afd7c

Please sign in to comment.