Improving the documentation

* Using the correct syntax highlighting language (eg. using twig instead of html)
* Fixing the indentation of one of the curl calls
* Using the correct comments (// in yaml is not a valid comment)
This commit is contained in:
mamazu 2022-01-23 20:27:31 +01:00 committed by Grzegorz Sadowski
parent 71fafc8639
commit ddc65335e6
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
11 changed files with 54 additions and 52 deletions

View file

@ -71,7 +71,7 @@ Lets assume that you would like to add a new permission to ACL. You will need
.. code-block:: yaml
// config/packages/_sylius.yaml
# config/packages/_sylius.yaml
...
sylius_plus:
@ -87,7 +87,7 @@ imported permissions with the same id in the ``config.yml``:
.. code-block:: yaml
// config/routes/sylius_admin.yaml
# config/routes/sylius_admin.yaml
...
app_admin_product_import:
@ -113,8 +113,8 @@ If you would like to modify an existing permission of for example the permission
.. code-block:: yaml
// config/packages/_sylius.yaml
...
# config/packages/_sylius.yaml
# ...
sylius_plus:
permissions:
@ -126,8 +126,8 @@ You can also modify the permission on the route is overwritten, only this will n
.. code-block:: yaml
// config/routes/sylius_admin.yaml
...
# config/routes/sylius_admin.yaml
# ...
sylius_admin_order_payment_complete:
path: /admin/orders/{orderId}/payments/{id}/complete
@ -148,8 +148,8 @@ If you want to remove a permission, you have to overwrite the permission configu
.. code-block:: yaml
// config/packages/_sylius.yaml
...
# config/packages/_sylius.yaml
# ...
sylius_plus:
permissions:
@ -161,7 +161,7 @@ id in the ``config.yml``:
.. code-block:: yaml
// config/routes/sylius_admin.yaml
# config/routes/sylius_admin.yaml
...
sylius_admin_order_payment_complete:

View file

@ -61,7 +61,7 @@ Installing Sylius Plus as a plugin to a Sylius application
# config/packages/_sylius.yaml
imports:
...
#...
- { resource: "@SyliusPlusPlugin/Resources/config/config.yaml" }
**5.** Configure Shop, Admin and Admin API routing:
@ -69,7 +69,7 @@ Installing Sylius Plus as a plugin to a Sylius application
.. code-block:: yaml
# config/routes/sylius_shop.yaml
...
#...
sylius_plus_shop:
resource: "@SyliusPlusPlugin/Resources/config/shop_routing.yaml"
@ -80,7 +80,7 @@ Installing Sylius Plus as a plugin to a Sylius application
.. code-block:: yaml
# config/routes/sylius_admin.yaml:
...
#...
sylius_plus_admin:
resource: "@SyliusPlusPlugin/Resources/config/admin_routing.yaml"

View file

@ -89,7 +89,7 @@ You can also change **maximum order item quantity** parameter in ``config/servic
.. code-block:: xml
# config/services.xml
<!-- config/services.xml -->
<parameters>
<parameter key="sylius.order_item_quantity_modifier.limit">9999</parameter> # by default it is 9999
</parameters>

View file

@ -30,47 +30,47 @@ Catalog Promotion has a few basic parameters that represent it - a unique ``code
The parameter ``code`` should contain only letters, numbers, dashes and underscores (like all codes in Sylius).
We encourage you to use ``snake_case`` codes.
.. code-block:: bash
.. code-block:: javascript
{
"code": "t_shirt_promotion" # unique
"code": "t_shirt_promotion" // unique
"name": "T-shirt Promotion"
# ...
// ...
}
Rest of the fields are used for configuration:
* **Channels** are used to define channels on which given promotion is applied:
.. code-block:: bash
.. code-block:: javascript
{
#...
//...
"channels": [
"/api/v2/admin/channels/FASHION_WEB", #IRI
"/api/v2/admin/channels/FASHION_WEB", //IRI
"/api/v2/admin/channels/HOME_WEB"
]
# ...
// ...
}
* **Scopes** are used to define scopes on which the catalog promotion will work:
.. code-block:: bash
.. code-block:: javascript
{
#...
//...
"scopes": [
{
"type": "for_variants",
"configuration": {
"variants": [
"Everyday_white_basic_T_Shirt-variant-1", #Variant Code
"Everyday_white_basic_T_Shirt-variant-1", //Variant Code
"Everyday_white_basic_T_Shirt-variant-4"
]
}
}
]
# ...
// ...
}
.. note::
@ -82,36 +82,36 @@ For possible scopes see `Catalog Promotion Scopes configuration reference`_
* **Actions** are used to defined what happens when the promotion is applied:
.. code-block:: bash
.. code-block:: javascript
{
#...
//...
"actions": [
{
"type": "percentage_discount",
"configuration": {
"amount": 0.5 #float
"amount": 0.5 //float
}
}
]
# ...
// ...
}
* **Translations** are used to define labels and descriptions for languages you are configuring:
.. code-block:: bash
.. code-block:: javascript
{
#...
//...
"translations": {
"en_US": {
"label": "Summer discount",
"description": "The grass so green, the sun so bright. Life seems a dream, no worries in sight.",
"locale": "en_US" #Locale Code
"locale": "en_US" //Locale Code
}
}
}
# ...
// ...
}
How to create a Catalog Promotion?
@ -251,13 +251,13 @@ If you look into ``product-variant`` endpoint in shop you should see now that ch
curl -X 'GET' \
'https://hostname/api/v2/shop/product-variant/Everyday_white_basic_T_Shirt-variant-1'
.. code-block:: bash
.. code-block:: javascript
# response content
// response content
{
"@context": "/api/v2/contexts/ProductVariant",
"@id": "/api/v2/shop/product-variants/Everyday_white_basic_T_Shirt-variant-1",
# ...
// ...
"price": 2000,
"originalPrice": 4000,
"appliedPromotions": {

View file

@ -82,6 +82,7 @@ Now with some magic of HTML and CSS we can modify this template, as an example w
<!--...-->
<div class="invoice-box" style="background-color: red">
<!--...-->
</div>
and after this change we are graced with this masterpiece:
@ -108,7 +109,7 @@ Because we are basing upon the existing field, there should be no problem adding
``Download/pdf.html.twig`` file. The ``Phone Number`` field is quite nested so you need to add ``invoice.order.customer.phoneNumber``
to retrieve it:
.. code-block:: html
.. code-block:: twig
<!--...-->
{{ invoice.billingData.city }}<br/>
@ -133,7 +134,7 @@ Lets create now a new row where we will show ``Products total`` where only price
First let's add the new table row between other ``totals`` in ``pdf.html.twig``
.. code-block:: html
.. code-block:: twig
<!--...-->
<tr class="totals">
@ -148,6 +149,7 @@ First let's add the new table row between other ``totals`` in ``pdf.html.twig``
</tr>
<tr class="totals bold">
</tr>
<!--...-->
And now add the translation by creating file ``translations/messages.en.yaml`` and adding:

View file

@ -21,7 +21,7 @@ We should start from creating a provider that will return for us all of eligible
# config/services.yaml
App\Provider\ByPhraseVariantsProvider:
App\Provider\ByPhraseVariantsProvider:
arguments:
- '@sylius.repository.product_variant'
tags:
@ -126,9 +126,9 @@ Prepare a configuration form type for your new scope
To be able to configure a Catalog Promotion with your new Scope you will need a form type for the admin panel.
With current implementation first you need to create a twig template for new Scope:
.. code-block:: html
.. code-block:: twig
# templates/bundles/SyliusAdminBundle/CatalogPromotion/Scope/by_phrase.html.twig
{# templates/bundles/SyliusAdminBundle/CatalogPromotion/Scope/by_phrase.html.twig #}
{% form_theme field '@SyliusAdmin/Form/theme.html.twig' %}
@ -140,7 +140,7 @@ Now let's create a form type and declare it service:
# config/services.yaml
App\Form\Type\CatalogPromotionScope\ByPhraseScopeConfigurationType:
App\Form\Type\CatalogPromotionScope\ByPhraseScopeConfigurationType:
arguments:
- '@sylius.repository.product_variant'
tags:

View file

@ -126,7 +126,7 @@ You will achieve that by overriding two files:
* `ShopBundle/Resources/views/Checkout/_steps.html.twig <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/_steps.html.twig>`_
* `ShopBundle/Resources/views/Checkout/SelectPayment/_navigation.html.twig <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/SelectPayment/_navigation.html.twig>`_
.. code-block:: html
.. code-block:: twig
{# templates/SyliusShopBundle/Checkout/_steps.html.twig #}
{% if active is not defined or active == 'address' %}
@ -170,7 +170,7 @@ You will achieve that by overriding two files:
</div>
</div>
.. code-block:: html
.. code-block:: twig
{# templates/SyliusShopBundle/Checkout/SelectPayment/_navigation.html.twig #}
{% set enabled = order.payments|length %}

View file

@ -19,7 +19,7 @@ Let's assume that you want to have your own prefixes on paths (for example to be
As the first step you need to change the ``paths`` or ``route_prefix`` attribute in all needed resources.
The next step is to modify the security configuration in ``config/packages/security.yaml``, you need to overwrite the parameter:
.. code-block:: xml
.. code-block:: yaml
parameters:
sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/retail"

View file

@ -108,7 +108,7 @@ As a result you will get the ``Sylius\Bundle\CustomerBundle\Form\Type\CustomerPr
In our case you will need to copy the original template from ``vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Account/profileUpdate.html.twig``
to ``templates/bundles/SyliusShopBundle/Account/`` and add the fields inside the copy.
.. code-block:: html
.. code-block:: twig
{{ form_row(form.phoneNumber) }}
{{ form_row(form.subscribedToNewsletter) }}

View file

@ -90,7 +90,7 @@ in the calculator service, and a proper service registration in the ``services.y
# config/services.yml
services:
//...
# ...
App\ShippingCalculator\ParcelCalculator:
tags:

View file

@ -113,9 +113,9 @@ Now let's add some product to this cart, first we need the ProductVariant IRI, w
and let's take first variant `@id` from list:
.. code-block:: bash
.. code-block:: javascript
# ...
// ...
{
"@id": "/api/v2/shop/product-variants/Everyday_white_basic_T_Shirt-variant-0",
"@type": "ProductVariant",
@ -138,7 +138,7 @@ and let's take first variant `@id` from list:
"originalPrice": 6420,
"inStock": true
}
# ...
// ...
Then going back to cart - let's add the variant to our cart with:
@ -268,9 +268,9 @@ We can get it from the address response or call once again all data about order
.. code-block:: bash
curl -X 'GET' \
'https://master.demo.sylius.com/api/v2/shop/orders/rl1KwtiSLA' \
-H 'accept: application/ld+json' \
-H 'Authorization: Bearer token'
'https://master.demo.sylius.com/api/v2/shop/orders/rl1KwtiSLA' \
-H 'accept: application/ld+json' \
-H 'Authorization: Bearer token'
In response we need to find payment and shipment where everyone of them has the required fields.