Как очистить корзину minishop2 в контексте, отличном от web?

To clear the minishop2 cart in a context other than "web", you'll need to write a custom snippet that interacts with the minishop2 API. Here's a step-by-step guide on how to achieve this:

1. In your MODX installation, navigate to the "Elements" section and create a new snippet. Give it a meaningful name, such as "ClearCartInContext".

2. In the snippet content, you'll need to include the following code to load the necessary minishop2 classes:

<?php
require_once MODX_BASE_PATH . 'assets/plugins/minishop2/model/minishop2/msOrder.php';
require_once MODX_BASE_PATH . 'assets/plugins/minishop2/model/minishop2/msProduct.php';

3. Next, you'll need to initialize the minishop2 context by setting the context key and loading the corresponding class:

<?php
$contextKey = 'your_context_key';
$modx->switchContext($contextKey);

Replace 'your_context_key' with the actual context key that you want to clear the cart in.

4. Now, you can use the minishop2 API to clear the cart by executing the following code:

<?php
$cart = msOrder::getInstance($modx);
$cart->clear();

5. Finally, you'll need to clear the cache to reflect these changes on the frontend. You can use the following code to clear the cache programmatically:

<?php
$modx->cacheManager->refresh();

That's it! You've successfully created a custom snippet that clears the minishop2 cart in a context other than "web". To use this snippet, simply call it in a resource or template as you would with any other MODX snippet:

[[ClearCartInContext]]

Please note that this solution assumes you already have minishop2 properly installed and configured for the desired context. If you encounter any issues, make sure to check your minishop2 configuration and consult the official minishop2 documentation.