> For the complete documentation index, see [llms.txt](https://vyvojari.retailys.cz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vyvojari.retailys.cz/priklady-aplikaci.md).

# Příklady

## Callbacky

### Post Shopping Cart Checkout Callback

Zde je příklad vytvoření callbacku pro platební bránu pro vytvoření platby. Je třeba splnit podmínky.

```php
$callbackId = $retailysService->postShoppingCartCheckoutCallback($token, [
                    'position' => 'payment',
                    'path' => 'create-payment',
                    'method' => 'POST',
                    'redirect' => true,
                    'parameters' => [
                        [
                            'name' => 'orderId',
                            'variable' => '%orderId%',
                        ],
                        [
                            'name' => 'channelId',
                            'variable' => '%channelId%',
                        ],
                    ],
                    'condition' => '%channelId% == '.$existingChannel->getChannelId().' and %paymentProvider% == 9',
                ]);
```

{% hint style="info" %}
Endpoint  [/System/Layouts/Eshop/ShoppingCart/Checkout/Callbacks](https://api.retailys.com/v1#/System.Layouts.Eshop/postEshopShoppingCartCheckoutCallbacks) na API můžete snadno vyzkoušet.
{% endhint %}

## Vykreslení šablony

Zde je příklad, jak vykreslit šablonu, do které jsou vloženy proměnné. Je zde vrácena v JSON.

```
$snippet = $this->renderView('config/save.html.twig', [
            'config' => $config,
            'channelsData' => $channelsData,
            'configChannels' => $configChannels,
        ]);

        return $this->json(
            [
                'snippet' => $snippet,
            ]
        );
```

## Snippety

### Static Snippet

#### Post Layout

Vytvořit statický snippet v layoutu eshopu

```
$snippetId = $retailysService->postLayoutStaticSnippet($token, [
                    'position' => 'footer',
                    'raw' => $this->renderView('snippet/variable.html.twig', [
                        'variable' => $channel->getVariable(),
                    ]),
                    'condition' => '%channelId% == '.$channel->getChannelId(),
                ]);
```

{% hint style="info" %}
Endpoint [/System/Layouts/Eshop/Layout/StaticSnippets](https://api.retailys.com/v1#/System.Layouts.Eshop/postEshopLayoutStaticSnippets) na API můžete snadno vyzkoušet.
{% endhint %}

#### Put Layout

Aktualizovat statický snippet v layoutu eshopu

```
$snippetResult = $retailysService->putLayoutStaticSnippet($token, [
                    'id' => $channel->getSnippetId(),
                    'position' => 'footer',
                    'raw' => $this->renderView('snippet/variable.html.twig', [
                        'variable' => $channel->getVariable(),
                    ]),
                    'condition' => '%channelId% == '.$channel->getChannelId(),
                ]);
```

{% hint style="info" %}
Endpoint [/System/Layouts/Eshop/Layout/StaticSnippets](https://api.retailys.com/v1#/System.Layouts.Eshop/putEshopLayoutStaticSnippets) na API můžete snadno vyzkoušet.
{% endhint %}

### Dynamic Snippet

#### PostDynamicSnippet

Na děkovnou stránku v košíku eshopu.

```
$dynamicSnippetId = $retailysService->postShippingCartThankYouDynamicSnippet($token, [
                        'position' => 'footer',
                        'type' => 'twig',
                        'template' => $this->renderView('snippet/example.html.twig', [
                          'variable' => $channel->getVariable(),
                        ]),
                        'condition' => '%channelId% == '.$channel->getChannelId(),
                    ]);
```

{% hint style="info" %}
Endpoint [/System/Layouts/Eshop/ShoppingCart/Thankyou/DynamicSnippets](https://api.retailys.com/v1#/System.Layouts.Eshop/postEshopShoppingCartThankyouDynamicSnippets) na API můžete snadno vyzkoušet.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://vyvojari.retailys.cz/priklady-aplikaci.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
