wip
This commit is contained in:
parent
d631949388
commit
d3d6dec4f0
22 changed files with 326 additions and 324 deletions
|
|
@ -10,7 +10,7 @@
|
|||
"language_server.diagnostics_on_save": true,
|
||||
"language_server.diagnostics_on_update": true,
|
||||
"language_server_highlight.enabled": true,
|
||||
"language_server_php_cs_fixer.enabled": true,
|
||||
"language_server_php_cs_fixer.enabled": false,
|
||||
"language_server_phpstan.config": "phpstan.neon",
|
||||
"language_server_phpstan.enabled": true,
|
||||
"language_server_psalm.enabled": false,
|
||||
|
|
|
|||
22
bun.lock
22
bun.lock
|
|
@ -268,11 +268,11 @@
|
|||
|
||||
"@effect/language-service": ["@effect/language-service@0.84.3", "", { "bin": { "effect-language-service": "cli.js" } }, "sha512-zpxi6rLCwst/cBQd7ElwDvt36Y6Jvz8v6bCLnNiOL6OXvdLmqjOFWyzWZdMh92vvBQA/aVKhfIAAOP3o4wKt0A=="],
|
||||
|
||||
"@emnapi/core": ["@emnapi/core@1.9.1", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.0", "tslib": "^2.4.0" } }, "sha512-mukuNALVsoix/w1BJwFzwXBN/dHeejQtuVzcDsfOEsdpCumXb/E9j8w11h5S54tT1xhifGfbbSm/ICrObRb3KA=="],
|
||||
"@emnapi/core": ["@emnapi/core@1.9.2", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.1", "tslib": "^2.4.0" } }, "sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA=="],
|
||||
|
||||
"@emnapi/runtime": ["@emnapi/runtime@1.9.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-VYi5+ZVLhpgK4hQ0TAjiQiZ6ol0oe4mBx7mVv7IflsiEp0OWoVsp/+f9Vc1hOhE0TtkORVrI1GvzyreqpgWtkA=="],
|
||||
"@emnapi/runtime": ["@emnapi/runtime@1.9.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw=="],
|
||||
|
||||
"@emnapi/wasi-threads": ["@emnapi/wasi-threads@1.2.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg=="],
|
||||
"@emnapi/wasi-threads": ["@emnapi/wasi-threads@1.2.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w=="],
|
||||
|
||||
"@es-joy/jsdoccomment": ["@es-joy/jsdoccomment@0.86.0", "", { "dependencies": { "@types/estree": "^1.0.8", "@typescript-eslint/types": "^8.58.0", "comment-parser": "1.4.6", "esquery": "^1.7.0", "jsdoc-type-pratt-parser": "~7.2.0" } }, "sha512-ukZmRQ81WiTpDWO6D/cTBM7XbrNtutHKvAVnZN/8pldAwLoJArGOvkNyxPTBGsPjsoaQBJxlH+tE2TNA/92Qgw=="],
|
||||
|
||||
|
|
@ -580,7 +580,7 @@
|
|||
|
||||
"@types/ms": ["@types/ms@2.1.0", "", {}, "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="],
|
||||
|
||||
"@types/node": ["@types/node@25.5.1", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-lgrR3HRNQdTEeeXBnLURFO4JIIbpcVcMlLM9IG0jsNRTRNSbMkm9S2hyhxhnokke1NM25Dr9QghgeB5PQKolrw=="],
|
||||
"@types/node": ["@types/node@25.5.2", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-tO4ZIRKNC+MDWV4qKVZe3Ql/woTnmHDr5JD8UI5hn2pwBrHEwOEMZK7WlNb5RKB6EoJ02gwmQS9OrjuFnZYdpg=="],
|
||||
|
||||
"@types/trusted-types": ["@types/trusted-types@2.0.7", "", {}, "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw=="],
|
||||
|
||||
|
|
@ -798,7 +798,7 @@
|
|||
|
||||
"effect": ["effect@4.0.0-beta.43", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "fast-check": "^4.5.3", "find-my-way-ts": "^0.1.6", "ini": "^6.0.0", "kubernetes-types": "^1.30.0", "msgpackr": "^1.11.8", "multipasta": "^0.2.7", "toml": "^3.0.0", "uuid": "^13.0.0", "yaml": "^2.8.2" } }, "sha512-AJYyDimIwJOn87uUz/JzmgDc5GfjxJbXvEbTvNzMa+M3Uer344bLo/O5mMRkqc1vBleA+Ygs4+dbE3QsqOkKTQ=="],
|
||||
|
||||
"electron-to-chromium": ["electron-to-chromium@1.5.330", "", {}, "sha512-jFNydB5kFtYUobh4IkWUnXeyDbjf/r9gcUEXe1xcrcUxIGfTdzPXA+ld6zBRbwvgIGVzDll/LTIiDztEtckSnA=="],
|
||||
"electron-to-chromium": ["electron-to-chromium@1.5.331", "", {}, "sha512-IbxXrsTlD3hRodkLnbxAPP4OuJYdWCeM3IOdT+CpcMoIwIoDfCmRpEtSPfwBXxVkg9xmBeY7Lz2Eo2TDn/HC3Q=="],
|
||||
|
||||
"emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="],
|
||||
|
||||
|
|
@ -1232,7 +1232,7 @@
|
|||
|
||||
"node-gyp-build-optional-packages": ["node-gyp-build-optional-packages@5.2.2", "", { "dependencies": { "detect-libc": "^2.0.1" }, "bin": { "node-gyp-build-optional-packages": "bin.js", "node-gyp-build-optional-packages-optional": "optional.js", "node-gyp-build-optional-packages-test": "build-test.js" } }, "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw=="],
|
||||
|
||||
"node-releases": ["node-releases@2.0.36", "", {}, "sha512-TdC8FSgHz8Mwtw9g5L4gR/Sh9XhSP/0DEkQxfEFXOpiul5IiHgHan2VhYYb6agDSfp4KuvltmGApc8HMgUrIkA=="],
|
||||
"node-releases": ["node-releases@2.0.37", "", {}, "sha512-1h5gKZCF+pO/o3Iqt5Jp7wc9rH3eJJ0+nh/CIoiRwjRxde/hAHyLPXYN4V3CqKAbiZPSeJFSWHmJsbkicta0Eg=="],
|
||||
|
||||
"normalize-path": ["normalize-path@3.0.0", "", {}, "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="],
|
||||
|
||||
|
|
@ -1380,7 +1380,7 @@
|
|||
|
||||
"safe-regex-test": ["safe-regex-test@1.1.0", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "is-regex": "^1.2.1" } }, "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw=="],
|
||||
|
||||
"sass": ["sass@1.98.0", "", { "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.1.5", "source-map-js": ">=0.6.2 <2.0.0" }, "optionalDependencies": { "@parcel/watcher": "^2.4.1" }, "bin": { "sass": "sass.js" } }, "sha512-+4N/u9dZ4PrgzGgPlKnaaRQx64RO0JBKs9sDhQ2pLgN6JQZ25uPQZKQYaBJU48Kd5BxgXoJ4e09Dq7nMcOUW3A=="],
|
||||
"sass": ["sass@1.99.0", "", { "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.1.5", "source-map-js": ">=0.6.2 <2.0.0" }, "optionalDependencies": { "@parcel/watcher": "^2.4.1" }, "bin": { "sass": "sass.js" } }, "sha512-kgW13M54DUB7IsIRM5LvJkNlpH+WhMpooUcaWGFARkF1Tc82v9mIWkCbCYf+MBvpIUBSeSOTilpZjEPr2VYE6Q=="],
|
||||
|
||||
"sass-embedded": ["sass-embedded@1.99.0", "", { "dependencies": { "@bufbuild/protobuf": "^2.5.0", "colorjs.io": "^0.5.0", "immutable": "^5.1.5", "rxjs": "^7.4.0", "supports-color": "^8.1.1", "sync-child-process": "^1.0.2", "varint": "^6.0.0" }, "optionalDependencies": { "sass-embedded-all-unknown": "1.99.0", "sass-embedded-android-arm": "1.99.0", "sass-embedded-android-arm64": "1.99.0", "sass-embedded-android-riscv64": "1.99.0", "sass-embedded-android-x64": "1.99.0", "sass-embedded-darwin-arm64": "1.99.0", "sass-embedded-darwin-x64": "1.99.0", "sass-embedded-linux-arm": "1.99.0", "sass-embedded-linux-arm64": "1.99.0", "sass-embedded-linux-musl-arm": "1.99.0", "sass-embedded-linux-musl-arm64": "1.99.0", "sass-embedded-linux-musl-riscv64": "1.99.0", "sass-embedded-linux-musl-x64": "1.99.0", "sass-embedded-linux-riscv64": "1.99.0", "sass-embedded-linux-x64": "1.99.0", "sass-embedded-unknown-all": "1.99.0", "sass-embedded-win32-arm64": "1.99.0", "sass-embedded-win32-x64": "1.99.0" }, "bin": { "sass": "dist/bin/sass.js" } }, "sha512-gF/juR1aX02lZHkvwxdF80SapkQeg2fetoDF6gIQkNbSw5YEUFspMkyGTjPjgZSgIHuZpy+Wz4PlebKnLXMjdg=="],
|
||||
|
||||
|
|
@ -1632,8 +1632,6 @@
|
|||
|
||||
"@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="],
|
||||
|
||||
"@gcch/configuration-eslint/eslint-plugin-perfectionist": ["eslint-plugin-perfectionist@5.7.0", "", { "dependencies": { "@typescript-eslint/utils": "^8.57.1", "natural-orderby": "^5.0.0" }, "peerDependencies": { "eslint": "^8.45.0 || ^9.0.0 || ^10.0.0" } }, "sha512-WRHj7OZS/INutQ/gKN5C1ZGnMhkQ3oKZQAA2I7rl5yM8keBtSd9oj/qlJaHuwh5873FhMPqYlttcadF0YsTN7g=="],
|
||||
|
||||
"@keyv/bigmap/keyv": ["keyv@5.6.0", "", { "dependencies": { "@keyv/serialize": "^1.1.1" } }, "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw=="],
|
||||
|
||||
"@typescript-eslint/eslint-plugin/ignore": ["ignore@7.0.5", "", {}, "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg=="],
|
||||
|
|
@ -1648,8 +1646,6 @@
|
|||
|
||||
"browserslist-to-esbuild/meow": ["meow@13.2.0", "", {}, "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA=="],
|
||||
|
||||
"bun-types/@types/node": ["@types/node@25.5.0", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-jp2P3tQMSxWugkCUKLRPVUpGaL5MVFwF8RDuSRztfwgN1wmqJeMSbKlnEtQqU8UrhTmzEmZdu2I6v2dpp7XIxw=="],
|
||||
|
||||
"cacheable/keyv": ["keyv@5.6.0", "", { "dependencies": { "@keyv/serialize": "^1.1.1" } }, "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw=="],
|
||||
|
||||
"clean-regexp/escape-string-regexp": ["escape-string-regexp@1.0.5", "", {}, "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg=="],
|
||||
|
|
@ -1678,10 +1674,6 @@
|
|||
|
||||
"rolldown/@oxc-project/types": ["@oxc-project/types@0.122.0", "", {}, "sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA=="],
|
||||
|
||||
"sass-embedded-all-unknown/sass": ["sass@1.99.0", "", { "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.1.5", "source-map-js": ">=0.6.2 <2.0.0" }, "optionalDependencies": { "@parcel/watcher": "^2.4.1" }, "bin": { "sass": "sass.js" } }, "sha512-kgW13M54DUB7IsIRM5LvJkNlpH+WhMpooUcaWGFARkF1Tc82v9mIWkCbCYf+MBvpIUBSeSOTilpZjEPr2VYE6Q=="],
|
||||
|
||||
"sass-embedded-unknown-all/sass": ["sass@1.99.0", "", { "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.1.5", "source-map-js": ">=0.6.2 <2.0.0" }, "optionalDependencies": { "@parcel/watcher": "^2.4.1" }, "bin": { "sass": "sass.js" } }, "sha512-kgW13M54DUB7IsIRM5LvJkNlpH+WhMpooUcaWGFARkF1Tc82v9mIWkCbCYf+MBvpIUBSeSOTilpZjEPr2VYE6Q=="],
|
||||
|
||||
"stylelint/file-entry-cache": ["file-entry-cache@11.1.2", "", { "dependencies": { "flat-cache": "^6.1.20" } }, "sha512-N2WFfK12gmrK1c1GXOqiAJ1tc5YE+R53zvQ+t5P8S5XhnmKYVB5eZEiLNZKDSmoG8wqqbF9EXYBBW/nef19log=="],
|
||||
|
||||
"stylelint/ignore": ["ignore@7.0.5", "", {}, "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg=="],
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
allow_url_fopen=0
|
||||
allow_url_include=0
|
||||
cgi.fix_pathinfo=0
|
||||
display_errors=0
|
||||
display_startup_errors=0
|
||||
expose_php=0
|
||||
allow_url_fopen=Off
|
||||
allow_url_include=Off
|
||||
cgi.fix_pathinfo=Off
|
||||
display_errors=On
|
||||
display_startup_errors=On
|
||||
expose_php=Off
|
||||
file_uploads=On
|
||||
html_errors=On
|
||||
error_prepend_string="<pre style='white-space: preserve'>"
|
||||
error_append_string="</pre>"
|
||||
max_execution_time=600
|
||||
max_input_time=600
|
||||
max_input_vars=2000
|
||||
|
|
|
|||
1
justfile
1
justfile
|
|
@ -29,7 +29,6 @@ format:
|
|||
# PhpCsFixer
|
||||
# -vendor/bin/php-cs-fixer fix --allow-risky yes
|
||||
dprint --config "~/.config/dprint/dprint.jsonc" fmt
|
||||
mago format
|
||||
fish scripts/format-sort-files.fish
|
||||
|
||||
# Compile, minifie et optimise Sass vers CSS.
|
||||
|
|
|
|||
76
mago.toml
76
mago.toml
|
|
@ -8,82 +8,6 @@ threads = 8
|
|||
includes = ["config", "vendor", "web/app/plugins", "web/vendor", "web/wp"]
|
||||
paths = ["web/app/themes/haiku-atelier-2024"]
|
||||
|
||||
[formatter]
|
||||
# Brace style for classes, traits, etc.
|
||||
classlike-brace-style = "same_line"
|
||||
# Brace style for closures.
|
||||
closure-brace-style = "same_line"
|
||||
# Brace style for control structures.
|
||||
control-brace-style = "same_line"
|
||||
# Brace style for functions.
|
||||
function-brace-style = "same_line"
|
||||
# Brace style for methods.
|
||||
method-brace-style = "same_line"
|
||||
# Maximum line length that the printer will wrap on.
|
||||
print-width = 120
|
||||
# Remove the trailing PHP close tag (?>) from files.
|
||||
remove-trailing-close-tag = true
|
||||
# Prefer single quotes over double quotes for strings.
|
||||
single-quote = true
|
||||
# Number of spaces per indentation level.
|
||||
tab-width = 2
|
||||
# Add a trailing comma to multi-line arrays, parameter lists, etc.
|
||||
trailing-comma = true
|
||||
# Use tabs instead of spaces for indentation.
|
||||
use-tabs = false
|
||||
# Place empty control structure bodies on the same line.
|
||||
inline-empty-control-braces = true
|
||||
# Place empty function bodies on the same line.
|
||||
inline-empty-function-braces = true
|
||||
# Place empty constructor bodies on the same line.
|
||||
inline-empty-constructor-braces = true
|
||||
# Place empty method bodies on the same line.
|
||||
inline-empty-method-braces = true
|
||||
# Place empty anonymous class bodies on the same line.
|
||||
inline-empty-anonymous-class-braces = true
|
||||
# How to break method chains.
|
||||
method-chain-breaking-style = "next_line"
|
||||
# Preserve existing line breaks in method chains.
|
||||
preserve-breaking-member-access-chain = false
|
||||
# Preserve existing line breaks in argument lists.
|
||||
preserve-breaking-argument-list = false
|
||||
# Preserve existing line breaks in array-like structures.
|
||||
preserve-breaking-array-like = false
|
||||
# Preserve existing line breaks in parameter lists.
|
||||
preserve-breaking-parameter-list = false
|
||||
# Preserve existing line breaks in attribute lists.
|
||||
preserve-breaking-attribute-list = false
|
||||
# Preserve existing line breaks in ternary expressions.
|
||||
preserve-breaking-conditional-expression = false
|
||||
# Always break parameter lists with promoted properties.
|
||||
break-promoted-properties-list = true
|
||||
# Place the binary operator on the next line when breaking.
|
||||
line-before-binary-operator = true
|
||||
# Always break named argument lists into multiple lines.
|
||||
always-break-named-arguments-list = true
|
||||
# Always break named argument lists in attributes.
|
||||
always-break-attribute-named-argument-lists = true
|
||||
# Use table-style alignment for arrays.
|
||||
array-table-style-alignment = true
|
||||
# Sort use statements alphabetically.
|
||||
sort-uses = true
|
||||
# Insert a blank line between different types of use statements.
|
||||
separate-use-types = true
|
||||
# Expand grouped use statements into individual statements.
|
||||
expand-use-groups = true
|
||||
# How to format null type hints (null|T vs ?T).
|
||||
null-type-hint = "null_pipe"
|
||||
# Add parentheses around new in member access ((new Foo)->bar()).
|
||||
parentheses-around-new-in-member-access = false
|
||||
# Add parentheses to new expressions without arguments (new Foo()).
|
||||
parentheses-in-new-expression = true
|
||||
# Add parentheses to exit and die constructs.
|
||||
parentheses-in-exit-and-die = true
|
||||
# Add parentheses to attributes without arguments.
|
||||
parentheses-in-attribute = true
|
||||
# Add a space before arrow function parameters.
|
||||
space-before-arrow-function-parameter-list-parenthesis = false
|
||||
|
||||
[linter]
|
||||
integrations = ["wordpress"]
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ $templates = ['accueil.twig'];
|
|||
*
|
||||
* @throws Exception une exception est levée s'il est impossible d'obtenir la date de modification du fichier à charger
|
||||
*/
|
||||
function load_resources(): void {
|
||||
function load_page_resources(): void {
|
||||
Resource::enqueue_style_file(
|
||||
handle: 'haiku-atelier-2024-styles-page-accueil',
|
||||
path: '/assets/css/pages/page-accueil.css',
|
||||
|
|
@ -33,7 +33,7 @@ function load_resources(): void {
|
|||
);
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', load_resources(...));
|
||||
add_action('wp_enqueue_scripts', load_page_resources(...));
|
||||
|
||||
Timber::render(
|
||||
data: $context,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ $context['image_dimensions'] = $image_dimensions;
|
|||
*
|
||||
* @throws Exception une exception est levée s'il est impossible d'obtenir la date de modification du fichier à charger
|
||||
*/
|
||||
function load_resources(): void {
|
||||
function load_page_resources(): void {
|
||||
Resource::enqueue_style_file(
|
||||
handle: 'haiku-atelier-2024-styles-page-a-propos',
|
||||
path: '/assets/css/pages/page-a-propos.css',
|
||||
|
|
@ -45,7 +45,7 @@ function load_resources(): void {
|
|||
);
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', load_resources(...));
|
||||
add_action('wp_enqueue_scripts', load_page_resources(...));
|
||||
|
||||
Timber::render(
|
||||
data: $context,
|
||||
|
|
|
|||
|
|
@ -9,127 +9,47 @@ declare(strict_types=1);
|
|||
namespace HaikuAtelier;
|
||||
|
||||
use Exception;
|
||||
use HaikuAtelier\Data\Cart;
|
||||
use HaikuAtelier\WP\Resource;
|
||||
use Illuminate\Support\Number;
|
||||
use Timber\Timber;
|
||||
use WC_Shipping_Rate;
|
||||
|
||||
use function add_action;
|
||||
use function collect;
|
||||
use function Crell\fp\pipe;
|
||||
use function filemtime;
|
||||
use function genere_balise_img_multiformats;
|
||||
use function get_template_directory;
|
||||
use function get_template_directory_uri;
|
||||
use function is_bool;
|
||||
use function recupere_et_formate_attributs_produit;
|
||||
use function WC;
|
||||
use function wp_enqueue_script_module;
|
||||
use function wp_enqueue_style;
|
||||
|
||||
// Importe la fonction pour récupérer les informations affichées des Produits dans le Panier
|
||||
require_once __DIR__ . '/src/inc/TraitementInformations.php';
|
||||
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ['panier.twig'];
|
||||
|
||||
$allowed_countries = [
|
||||
'AD',
|
||||
'AL',
|
||||
'AM',
|
||||
'AR',
|
||||
'AT',
|
||||
'AU',
|
||||
'BA',
|
||||
'BE',
|
||||
'BG',
|
||||
'BR',
|
||||
'CA',
|
||||
'CH',
|
||||
'CL',
|
||||
'CR',
|
||||
'CU',
|
||||
'CY',
|
||||
'CZ',
|
||||
'DE',
|
||||
'DK',
|
||||
'DZ',
|
||||
'EE',
|
||||
'EG',
|
||||
'ES',
|
||||
'FI',
|
||||
'FR',
|
||||
'GF',
|
||||
'GP',
|
||||
'GR',
|
||||
'HR',
|
||||
'HU',
|
||||
'IE',
|
||||
'IS',
|
||||
'IT',
|
||||
'JP',
|
||||
'KR',
|
||||
'LB',
|
||||
'LI',
|
||||
'LT',
|
||||
'LU',
|
||||
'LV',
|
||||
'MA',
|
||||
'MD',
|
||||
'ME',
|
||||
'MF',
|
||||
'MQ',
|
||||
'MT',
|
||||
'MX',
|
||||
'NC',
|
||||
'NL',
|
||||
'NO',
|
||||
'NZ',
|
||||
'PF',
|
||||
'PL',
|
||||
'PM',
|
||||
'PS',
|
||||
'PT',
|
||||
'RE',
|
||||
'RO',
|
||||
'SE',
|
||||
'SI',
|
||||
'SK',
|
||||
'SM',
|
||||
'TN',
|
||||
'TR',
|
||||
'TW',
|
||||
'US',
|
||||
'YT',
|
||||
'ZA',
|
||||
];
|
||||
$context = Timber::context();
|
||||
$templates = ['panier.twig'];
|
||||
|
||||
// Récupère les informations affichés des Produits du Panier
|
||||
$cart = [];
|
||||
|
||||
/** Le sous-total de la Commande dans le Panier. */
|
||||
$cart_subtotal = WC()->cart->get_subtotal();
|
||||
/** @var array<string,int> */
|
||||
$cart_totals = WC()->cart->get_totals();
|
||||
|
||||
/** @var string|null $promo_code Le code promo appliqué au Panier s'il existe. */
|
||||
$promo_code = collect(WC()->cart->get_applied_coupons())->first();
|
||||
|
||||
/** @var array<string,int> */
|
||||
$cart_totals = WC()->cart->get_totals();
|
||||
/** Le sous-total de la Commande dans le Panier. */
|
||||
$cart_subtotal = Cart::parse_cart_value($cart_totals['subtotal'] ?? 0);
|
||||
|
||||
/** @var string $cart_subtotal_with_discount Le total du montant de la Réduction appliquée au Panier. */
|
||||
$cart_subtotal_with_discount = $cart_totals['discount_total']
|
||||
|> (static fn(int $number) => Number::format($number, maxPrecision: 2))
|
||||
|> (static fn(false|string $number) => is_bool($number) ? '0' : $number);
|
||||
/** @var float $cart_total Le total de la Commande dans le Panier. */
|
||||
$cart_total = $cart_totals['total']
|
||||
|> (static fn(int $number) => Number::format($number, maxPrecision: 2))
|
||||
|> (static fn(false|string $number) => is_bool($number) ? '0' : $number)
|
||||
|> (static fn(string $number) => (float) $number);
|
||||
/** @var string $shipping_subtotal Le sous-total de la livraison. */
|
||||
$shipping_subtotal = $cart_totals['shipping_total']
|
||||
|> (static fn(int $number) => Number::format($number, precision: 0))
|
||||
|> (static fn(false|string $number) => is_bool($number) ? '0' : $number);
|
||||
/** Le total du montant de la Réduction appliquée au Panier. */
|
||||
$cart_subtotal_with_discount = Cart::parse_cart_value($cart_totals['discount_total'] ?? 0);
|
||||
|
||||
/** Le total de la Commande dans le Panier. */
|
||||
$cart_total = Cart::parse_cart_value($cart_totals['total'] ?? 0);
|
||||
|
||||
/** Le sous-total de la livraison. */
|
||||
$shipping_subtotal = Cart::parse_cart_value($cart_totals['shipping_total'] ?? 0);
|
||||
|
||||
// TODO: Nettoyer ça.
|
||||
foreach (WC()->cart->get_cart() as $cle_panier => $article_panier) {
|
||||
$cart[$cle_panier] = [
|
||||
'attributs' => $article_panier['data']?->get_type() === 'variation'
|
||||
|
|
@ -154,35 +74,37 @@ $email = WC()->customer->get_billing_email();
|
|||
$adresse_livraison = WC()->customer->get_shipping();
|
||||
$adresse_facturation = WC()->customer->get_billing();
|
||||
$adresse_renseignee = $adresse_livraison['city'] !== '';
|
||||
$allowed_countries = collect(WC()->countries->get_countries())->only($allowed_countries)->toArray();
|
||||
// TODO: Déplacer ça dans une fonction statique de Cart.
|
||||
$allowed_countries = collect(WC()->countries->get_countries())->only(Cart::get_allowed_countries())->toArray();
|
||||
// TODO: Nettoyer ça.
|
||||
$methodes_livraison = collect(WC()->session->get('shipping_for_package_0')['rates'])
|
||||
->values()
|
||||
->map(static fn(WC_Shipping_Rate $methode): array => [
|
||||
'id' => $methode->get_method_id(),
|
||||
'prix' => Number::format((int) $methode->get_cost(), maxPrecision: 2),
|
||||
'prix' => Number::format((int) $methode->get_cost(), precision: 2),
|
||||
'selectionnee' => collect(WC()->session->get('chosen_shipping_methods'))->first() === $methode->get_id(),
|
||||
'titre' => $methode->get_label(),
|
||||
]);
|
||||
|
||||
$contexte['email'] = $email;
|
||||
$contexte['adresse_livraison'] = $adresse_livraison;
|
||||
$contexte['adresse_facturation'] = $adresse_facturation;
|
||||
$contexte['adresse_renseignee'] = $adresse_renseignee;
|
||||
$contexte['sous_total_panier'] = $cart_subtotal;
|
||||
$contexte['code_promo'] = $promo_code;
|
||||
$contexte['sous_total_reduction'] = $cart_subtotal_with_discount;
|
||||
$contexte['total_panier'] = $cart_total;
|
||||
$contexte['produits_panier'] = $cart;
|
||||
$contexte['pays_livraison'] = $allowed_countries;
|
||||
$contexte['sous_total_livraison'] = $shipping_subtotal;
|
||||
$contexte['methodes_livraison'] = $methodes_livraison;
|
||||
$context['email'] = $email;
|
||||
$context['adresse_livraison'] = $adresse_livraison;
|
||||
$context['adresse_facturation'] = $adresse_facturation;
|
||||
$context['adresse_renseignee'] = $adresse_renseignee;
|
||||
$context['sous_total_panier'] = $cart_subtotal;
|
||||
$context['code_promo'] = $promo_code;
|
||||
$context['sous_total_reduction'] = $cart_subtotal_with_discount;
|
||||
$context['total_panier'] = $cart_total;
|
||||
$context['produits_panier'] = $cart;
|
||||
$context['pays_livraison'] = $allowed_countries;
|
||||
$context['sous_total_livraison'] = $shipping_subtotal;
|
||||
$context['methodes_livraison'] = $methodes_livraison;
|
||||
|
||||
/**
|
||||
* Charge les scripts et styles de la page.
|
||||
*
|
||||
* @throws Exception une exception est levée s'il est impossible d'obtenir la date de modification du fichier à charger
|
||||
*/
|
||||
function load_resources(): void {
|
||||
function load_page_resources(): void {
|
||||
Resource::enqueue_style_file(
|
||||
handle: 'haiku-atelier-2024-styles-page-panier',
|
||||
path: '/assets/css/pages/page-panier.css',
|
||||
|
|
@ -193,10 +115,10 @@ function load_resources(): void {
|
|||
);
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', load_resources(...));
|
||||
add_action('wp_enqueue_scripts', load_page_resources(...));
|
||||
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
data: $contexte,
|
||||
filenames: $templates,
|
||||
data: $context,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,23 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Route pour la préparation du paiement via Stripe (« Checkout »).
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace HaikuAtelier;
|
||||
|
||||
use Roots\WPConfig\Config;
|
||||
use Stripe\BillingPortal\Session;
|
||||
use Stripe\Checkout\Session;
|
||||
use Stripe\Coupon;
|
||||
use Stripe\Product;
|
||||
use Stripe\Stripe;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use WC_Cart;
|
||||
use WC_Coupon;
|
||||
use WC_Order;
|
||||
use WC_Session_Handler;
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
|
|
@ -140,7 +146,7 @@ $reductions_stripe = $coupons_wc
|
|||
->toArray();
|
||||
|
||||
/** @var Session $session_checkout_stripe */
|
||||
$session_checkout_stripe = \Stripe\Checkout\Session::create([
|
||||
$session_checkout_stripe = Session::create([
|
||||
'cancel_url' => $urls['echec_commande'],
|
||||
'customer_email' => $email_client,
|
||||
'discounts' => $reductions_stripe,
|
||||
|
|
|
|||
|
|
@ -3,30 +3,36 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Modèle de la Page Contact.
|
||||
* Modèle de la Page « Contact ».
|
||||
*/
|
||||
|
||||
namespace HaikuAtelier;
|
||||
|
||||
use Exception;
|
||||
use HaikuAtelier\WP\Resource;
|
||||
use Timber\Timber;
|
||||
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ['contact.twig'];
|
||||
use function add_action;
|
||||
|
||||
// Charge les scripts et styles de la page
|
||||
function charge_scripts_styles_page_contact(): void {
|
||||
wp_enqueue_style(
|
||||
$context = Timber::context();
|
||||
$templates = ['contact.twig'];
|
||||
|
||||
/**
|
||||
* Charge les scripts et styles de la page.
|
||||
*
|
||||
* @throws Exception une exception est levée s'il est impossible d'obtenir la date de modification du fichier à charger
|
||||
*/
|
||||
function load_page_resources(): void {
|
||||
Resource::enqueue_style_file(
|
||||
handle: 'haiku-atelier-2024-styles-page-contact',
|
||||
src: get_template_directory_uri() . '/assets/css/pages/page-modele-simple.css',
|
||||
deps: [],
|
||||
ver: filemtime(get_template_directory() . '/assets/css/pages/page-modele-simple.css'),
|
||||
media: 'all',
|
||||
path: '/assets/css/pages/page-contact.css',
|
||||
);
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', 'charge_scripts_styles_page_contact');
|
||||
add_action('wp_enqueue_scripts', load_page_resources(...));
|
||||
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
data: $contexte,
|
||||
filenames: $templates,
|
||||
data: $context,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,32 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Route pour la préparation du paiement via Stripe (« Checkout »).
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Modèle de la Page affichée à l'utilisateur lors de l'échec d'un paiement « Failed Order ».
|
||||
*/
|
||||
|
||||
namespace HaikuAtelier;
|
||||
|
||||
use Exception;
|
||||
use HaikuAtelier\WP\Resource;
|
||||
use Timber\Timber;
|
||||
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ['echec-commande.twig'];
|
||||
use function add_action;
|
||||
|
||||
// Charge les scripts et styles de la page
|
||||
function charge_scripts_styles_page_echec_commande(): void {
|
||||
wp_enqueue_style(
|
||||
handle: 'haiku-atelier-2024-styles-page-a-propos',
|
||||
src: get_template_directory_uri() . '/assets/css/pages/page-modele-simple.css',
|
||||
deps: [],
|
||||
ver: filemtime(get_template_directory() . '/assets/css/pages/page-modele-simple.css'),
|
||||
media: 'all',
|
||||
$context = Timber::context();
|
||||
$templates = ['echec-commande.twig'];
|
||||
|
||||
/**
|
||||
* Charge les scripts et styles de la page.
|
||||
*
|
||||
* @throws Exception une exception est levée s'il est impossible d'obtenir la date de modification du fichier à charger
|
||||
*/
|
||||
function load_page_resources(): void {
|
||||
Resource::enqueue_style_file(
|
||||
handle: 'haiku-atelier-2024-styles-page-modele-simple',
|
||||
path: '/assets/css/pages/page-modele-simple.css',
|
||||
);
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', 'charge_scripts_styles_page_echec_commande');
|
||||
add_action('wp_enqueue_scripts', load_page_resources(...));
|
||||
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
data: $contexte,
|
||||
filenames: $templates,
|
||||
data: $context,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,20 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Route pour la préparation du paiement via Stripe (« Checkout »).
|
||||
* Modèle de la Page affichée à l'utilisateur lors du succès d'un paiement « Succesful Order ».
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace HaikuAtelier;
|
||||
|
||||
use Roots\WPConfig\Config;
|
||||
use Stripe\Checkout\Session;
|
||||
use Stripe\StripeClient;
|
||||
use Timber\Timber;
|
||||
use WC_Cart;
|
||||
use WC_Order;
|
||||
use WC_Order_Refund;
|
||||
|
||||
use function Crell\fp\pipe;
|
||||
|
||||
|
|
@ -57,9 +62,8 @@ try {
|
|||
$panier->empty_cart();
|
||||
}
|
||||
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ['succes-commande.twig'];
|
||||
$context = Timber::context();
|
||||
$templates = ['succes-commande.twig'];
|
||||
|
||||
// Récupère les données des Produits
|
||||
/** @var mixed $produits Les Produits de la Commande sous forme de tableau contenant uniquement les données affichées nécessaires pour le Page. */
|
||||
|
|
@ -94,7 +98,7 @@ try {
|
|||
];
|
||||
});
|
||||
|
||||
$contexte['produits'] = $produits;
|
||||
$context['produits'] = $produits;
|
||||
|
||||
// Charge les scripts et styles de la page
|
||||
function charge_scripts_styles_page_succes_commande(): void {
|
||||
|
|
@ -111,8 +115,8 @@ try {
|
|||
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
data: $contexte,
|
||||
filenames: $templates,
|
||||
data: $context,
|
||||
);
|
||||
} catch (Error $error) {
|
||||
http_response_code(500);
|
||||
|
|
|
|||
|
|
@ -6,27 +6,31 @@ declare(strict_types=1);
|
|||
* Le modèle de la Page « Terms & Conditions ».
|
||||
*/
|
||||
|
||||
namespace HaikuAtelier;
|
||||
|
||||
use Exception;
|
||||
use HaikuAtelier\WP\Resource;
|
||||
use Timber\Timber;
|
||||
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ['cgv.twig'];
|
||||
$context = Timber::context();
|
||||
$templates = ['cgv.twig'];
|
||||
|
||||
// Charge les scripts et styles de la page
|
||||
function charge_scripts_styles_page_cgv(): void {
|
||||
wp_enqueue_style(
|
||||
handle: 'haiku-atelier-2024-styles-page-cgv',
|
||||
src: get_template_directory_uri() . '/assets/css/pages/page-modele-simple.css',
|
||||
deps: [],
|
||||
ver: filemtime(get_template_directory() . '/assets/css/pages/page-modele-simple.css'),
|
||||
media: 'all',
|
||||
/**
|
||||
* Charge les scripts et styles de la page.
|
||||
*
|
||||
* @throws Exception une exception est levée s'il est impossible d'obtenir la date de modification du fichier à charger
|
||||
*/
|
||||
function load_page_resources(): void {
|
||||
Resource::enqueue_style_file(
|
||||
handle: '/assets/css/pages/page-modele-simple.css',
|
||||
path: '/assets/css/pages/page-modele-simple.css',
|
||||
);
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', 'charge_scripts_styles_page_cgv');
|
||||
add_action('wp_enqueue_scripts', load_page_resources(...));
|
||||
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
data: $contexte,
|
||||
filenames: $templates,
|
||||
data: $context,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -6,33 +6,50 @@ declare(strict_types=1);
|
|||
* Le modèle de la Page d'un Produit.
|
||||
*/
|
||||
|
||||
use HaikuAtelier\Data\Product;
|
||||
use Timber\Timber;
|
||||
namespace HaikuAtelier;
|
||||
|
||||
use Exception;
|
||||
use HaikuAtelier\Data\Product;
|
||||
use HaikuAtelier\WP\Resource;
|
||||
use Illuminate\Support\Arr;
|
||||
use stdClass;
|
||||
use Timber\Timber;
|
||||
use WC_Product;
|
||||
|
||||
use function add_action;
|
||||
use function assert;
|
||||
use function collect;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function recupere_produits_meme_collection;
|
||||
use function wc_get_product;
|
||||
use function wp_json_encode;
|
||||
|
||||
require_once __DIR__ . '/src/inc/HTML.php';
|
||||
require_once __DIR__ . '/src/inc/TraitementInformations.php';
|
||||
|
||||
// Contexte et modèles
|
||||
$context = Timber::context();
|
||||
$templates = ['produit.twig'];
|
||||
|
||||
$raw_product = wc_get_product();
|
||||
|
||||
// Le Produit DOIT exister.
|
||||
if ($raw_product === null || is_bool($raw_product)) {
|
||||
if ($raw_product === null || $raw_product === false) {
|
||||
throw new Exception("Le Produit n'existe pas.");
|
||||
}
|
||||
|
||||
// Assemble les données d'intérêt pour la page au sein d'une Classe.
|
||||
$product = Product::new($raw_product);
|
||||
|
||||
/** @var int $prix_maximal Le prix de la Variation la plus chère */
|
||||
/** @var int $maximum_price Le prix de la Variation la plus chère */
|
||||
$maximum_price = collect($product->variations)->max('price');
|
||||
|
||||
$same_collection_products = array_map(
|
||||
array: recupere_produits_meme_collection($product->collection)($product->id),
|
||||
callback: Product::new(...),
|
||||
);
|
||||
/** @var list<Product> Les Produits de la même collection que celui affiché dans la Page. */
|
||||
$same_collection_products = recupere_produits_meme_collection($product->collection)($product->id)
|
||||
|> function (/** @var list<WC_Product>|stdClass */ mixed $products): array {
|
||||
assert(is_array($products), 'Les Produits de la même collection doivent être un tableau.');
|
||||
return $products;
|
||||
}
|
||||
|> (static fn(/** @var list<WC_Product> */ array $products): array => Arr::map($products, Product::new(...)));
|
||||
|
||||
$context['product'] = $product;
|
||||
$context['product_json'] = wp_json_encode($product);
|
||||
|
|
@ -40,24 +57,22 @@ $context['maximum_price'] = $maximum_price;
|
|||
$context['same_collection_products'] = $same_collection_products;
|
||||
|
||||
/**
|
||||
* Charge les Scripts nécessaires pour la page Produit.
|
||||
* Charge les scripts et styles de la page.
|
||||
*
|
||||
* @throws Exception une exception est levée s'il est impossible d'obtenir la date de modification du fichier à charger
|
||||
*/
|
||||
function charge_scripts_page_produit(): void {
|
||||
wp_enqueue_script_module(
|
||||
function load_page_resources(): void {
|
||||
Resource::enqueue_script_module_file(
|
||||
id: 'haiku-atelier-2024-scripts-page-produit',
|
||||
src: get_template_directory_uri() . '/assets/js/scripts-page-produit.js',
|
||||
deps: [],
|
||||
version: filemtime(get_template_directory() . '/assets/js/scripts-page-produit.js'),
|
||||
path: '/assets/js/scripts-page-produit.js',
|
||||
);
|
||||
wp_enqueue_script_module(
|
||||
Resource::enqueue_script_module_file(
|
||||
id: 'haiku-atelier-2024-scripts-menu-categories',
|
||||
src: get_template_directory_uri() . '/assets/js/scripts-menu-categories.js',
|
||||
deps: [],
|
||||
version: filemtime(get_template_directory() . '/assets/js/scripts-menu-categories.js'),
|
||||
path: '/assets/js/scripts-menu-categories.js',
|
||||
);
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', 'charge_scripts_page_produit');
|
||||
add_action('wp_enqueue_scripts', load_page_resources(...));
|
||||
|
||||
// Rendu
|
||||
Timber::render(
|
||||
|
|
|
|||
|
|
@ -184,7 +184,6 @@ final class StarterSite extends Site {
|
|||
public function maj_environnement_twig(array $options): array {
|
||||
return $options;
|
||||
}
|
||||
|
||||
// public function charge_traductions_theme(): void {
|
||||
// load_theme_textdomain("haiku-atelier-2024", get_template_directory() . "/languages");
|
||||
// }
|
||||
|
|
|
|||
122
web/app/themes/haiku-atelier-2024/src/inc/Data/Cart.php
Normal file
122
web/app/themes/haiku-atelier-2024/src/inc/Data/Cart.php
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HaikuAtelier\Data;
|
||||
|
||||
use Illuminate\Support\Number;
|
||||
|
||||
use function is_bool;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_string;
|
||||
|
||||
final readonly class Cart {
|
||||
public function __construct() {}
|
||||
|
||||
/** La valeur par défaut d'une donnée invalide du Panier. */
|
||||
private const string DEFAULT_VALUE = '0.00';
|
||||
|
||||
/**
|
||||
* Retourne la liste des pays acceptés pour la livraison.
|
||||
*
|
||||
* @return array<int,string>
|
||||
*/
|
||||
public static function get_allowed_countries(): array {
|
||||
return [
|
||||
'AD',
|
||||
'AL',
|
||||
'AM',
|
||||
'AR',
|
||||
'AT',
|
||||
'AU',
|
||||
'BA',
|
||||
'BE',
|
||||
'BG',
|
||||
'BR',
|
||||
'CA',
|
||||
'CH',
|
||||
'CL',
|
||||
'CR',
|
||||
'CU',
|
||||
'CY',
|
||||
'CZ',
|
||||
'DE',
|
||||
'DK',
|
||||
'DZ',
|
||||
'EE',
|
||||
'EG',
|
||||
'ES',
|
||||
'FI',
|
||||
'FR',
|
||||
'GF',
|
||||
'GP',
|
||||
'GR',
|
||||
'HR',
|
||||
'HU',
|
||||
'IE',
|
||||
'IS',
|
||||
'IT',
|
||||
'JP',
|
||||
'KR',
|
||||
'LB',
|
||||
'LI',
|
||||
'LT',
|
||||
'LU',
|
||||
'LV',
|
||||
'MA',
|
||||
'MD',
|
||||
'ME',
|
||||
'MF',
|
||||
'MQ',
|
||||
'MT',
|
||||
'MX',
|
||||
'NC',
|
||||
'NL',
|
||||
'NO',
|
||||
'NZ',
|
||||
'PF',
|
||||
'PL',
|
||||
'PM',
|
||||
'PS',
|
||||
'PT',
|
||||
'RE',
|
||||
'RO',
|
||||
'SE',
|
||||
'SI',
|
||||
'SK',
|
||||
'SM',
|
||||
'TN',
|
||||
'TR',
|
||||
'TW',
|
||||
'US',
|
||||
'YT',
|
||||
'ZA',
|
||||
];
|
||||
}
|
||||
|
||||
public static function parse_cart_value(int|float|string|bool $cart_value): string {
|
||||
if (is_int($cart_value) || is_float($cart_value)) {
|
||||
return self::format_number($cart_value);
|
||||
}
|
||||
|
||||
if (is_string($cart_value)) {
|
||||
$number = Number::parseInt($cart_value);
|
||||
$number = is_bool($number) ? 0 : $number;
|
||||
|
||||
return self::format_number($number);
|
||||
}
|
||||
|
||||
return '0.00';
|
||||
}
|
||||
|
||||
private static function format_number(int|float $number): string {
|
||||
$formatted_number = Number::format(
|
||||
number: $number,
|
||||
// precision et max_precision sont mutuellement exclusifs.
|
||||
precision: 2,
|
||||
locale: 'fr',
|
||||
);
|
||||
return is_bool($formatted_number) ? self::DEFAULT_VALUE : $formatted_number;
|
||||
}
|
||||
}
|
||||
|
|
@ -205,9 +205,8 @@ function recupere_informations_produit_page_produit(WC_Product $product): mixed
|
|||
*
|
||||
* Pour faciliter l'usage avec `array_map`, utilise une fonction avec curryfication.
|
||||
*/
|
||||
function recupere_produits_meme_collection(string $slug_collection): mixed {
|
||||
// @param int $id_produit
|
||||
return static fn($id_produit) => wc_get_products([
|
||||
function recupere_produits_meme_collection(string $slug_collection): callable {
|
||||
return static fn(int $id_produit): array|stdClass => wc_get_products([
|
||||
'exclude' => [$id_produit],
|
||||
'limit' => 4,
|
||||
'order' => 'DESC',
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Description: Hé.
|
|||
Version: 1.0
|
||||
Requires at least: 5.0
|
||||
Tested up to: 5.4
|
||||
Requires PHP: 7.0
|
||||
Requires PHP: 8.5
|
||||
License: Tous droits réservés
|
||||
Text Domain: haiku-atelier-2024
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,19 +6,23 @@ declare(strict_types=1);
|
|||
* Le modèle de la Page d'Archive d'une Catégorie de Produits.
|
||||
*/
|
||||
|
||||
namespace HaikuAtelier;
|
||||
|
||||
use Exception;
|
||||
use HaikuAtelier\Data\Product;
|
||||
use HaikuAtelier\WP\Resource;
|
||||
use Illuminate\Support\Arr;
|
||||
use Timber\Timber;
|
||||
use WC_Product;
|
||||
use WP_Term;
|
||||
|
||||
require_once __DIR__ . '/src/inc/TraitementInformations.php';
|
||||
|
||||
// Contexte et modèles
|
||||
$context = Timber::context();
|
||||
$templates = ['boutique.twig'];
|
||||
|
||||
/** @var WP_Term */
|
||||
$current_term = get_queried_object();
|
||||
/** @var string */
|
||||
$category_slug = $current_term->slug;
|
||||
|
||||
/** @var list<WC_Product> $raw_products Les informations brutes des Produits. */
|
||||
|
|
@ -31,10 +35,7 @@ $raw_products = wc_get_products([
|
|||
]);
|
||||
|
||||
/** @var list<Product> */
|
||||
$products = array_map(
|
||||
callback: Product::new(...),
|
||||
array: $raw_products,
|
||||
);
|
||||
$products = Arr::map($raw_products, Product::new(...));
|
||||
$context['products'] = $products;
|
||||
|
||||
/** @var string */
|
||||
|
|
@ -61,7 +62,7 @@ function load_page_resources(): void {
|
|||
);
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', 'load_page_resources');
|
||||
add_action('wp_enqueue_scripts', load_page_resources(...));
|
||||
|
||||
// Rendu
|
||||
Timber::render(
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ if (!defined('ABSPATH')) {
|
|||
Timber::init();
|
||||
// Sélectionne le répertoire contenant les modèles Twig
|
||||
Timber::$dirname = ['views'];
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ['email-commande-envoyee.twig'];
|
||||
|
||||
$context = Timber::context();
|
||||
$templates = ['email-commande-envoyee.twig'];
|
||||
|
||||
/** @var Order $commande La Commande issue du contexte contenu dans la variable $order. */
|
||||
$commande = $order;
|
||||
|
|
@ -39,9 +39,9 @@ $email = [
|
|||
],
|
||||
];
|
||||
|
||||
$contexte['commande'] = $email;
|
||||
$context['commande'] = $email;
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
data: $contexte,
|
||||
filenames: $templates,
|
||||
data: $context,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ if (!defined('ABSPATH')) {
|
|||
Timber::init();
|
||||
// Sélectionne le répertoire contenant les modèles Twig
|
||||
Timber::$dirname = ['views'];
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ['email-base.twig'];
|
||||
|
||||
$context = Timber::context();
|
||||
$templates = ['email-base.twig'];
|
||||
|
||||
/** @var Order $commande La Commande issue du contexte contenu dans la variable $order. */
|
||||
$commande = $order;
|
||||
|
|
@ -74,9 +74,9 @@ $email = [
|
|||
$email['adresses']['livraison']['country'] = WC()->countries->countries[$commande->get_shipping_country()];
|
||||
$email['adresses']['facturation']['country'] = WC()->countries->countries[$commande->get_billing_country()];
|
||||
|
||||
$contexte['commande'] = $email;
|
||||
$context['commande'] = $email;
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
data: $contexte,
|
||||
filenames: $templates,
|
||||
data: $context,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ if (!defined('ABSPATH')) {
|
|||
Timber::init();
|
||||
// Sélectionne le répertoire contenant les modèles Twig
|
||||
Timber::$dirname = ['views'];
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ['email-commande-recue.twig'];
|
||||
|
||||
$context = Timber::context();
|
||||
$templates = ['email-commande-recue.twig'];
|
||||
|
||||
/** @var Order $commande La Commande issue du contexte contenu dans la variable $order. */
|
||||
$commande = $order;
|
||||
|
|
@ -70,10 +70,10 @@ $email = [
|
|||
$email['adresses']['livraison']['country'] = WC()->countries->countries[$commande->get_shipping_country()];
|
||||
$email['adresses']['facturation']['country'] = WC()->countries->countries[$commande->get_billing_country()];
|
||||
|
||||
$contexte['commande'] = $email;
|
||||
$context['commande'] = $email;
|
||||
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
data: $contexte,
|
||||
filenames: $templates,
|
||||
data: $context,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue