prestashop / module-lib-faq
允许模块从 PrestaShop 服务器加载常见问题解答(FAQ)内容的库
v2.2
2022-06-20 15:21 UTC
Requires
- php: ^7.2 || ^8.0
- prestashop/module-lib-guzzle-adapter: ^0
Requires (Dev)
- guzzlehttp/guzzle: ^7.4
- php-http/mock-client: ^1.5
- phpunit/phpunit: ~5.7
- prestashop/php-dev-tools: ^4.2
README
此库从 PrestaShop API 获取常见问题解答(FAQ)内容。
它最常用于 PrestaShop 模块,但也可以集成到任何 PHP 项目中。
此库与 PHP 5.6 及以上版本兼容。
安装
composer require prestashop/module-lib-faq
使用
-
常见情况
使用此库的最简单方法是
use PrestaShop\ModuleLibFaq\Faq; // [...] $faq = new Faq('your module key', _PS_VERSION, 'the current iso code'); $faqContent = $faq->getFaq();
-
添加额外的错误处理代码
use PrestaShop\ModuleLibFaq\Faq; // [...] $faq = new Faq('your module key', _PS_VERSION, 'the current iso code'); $faq->setErrorCallable(function(\Exception $e) { /* send to logger */ }); $faqContent = $faq->getFaq();
返回的内容是一个数组,包含类别,每个类别都有一个问题和答案的数组。
库将解码的 json 示例
{ "id_faq": 117, "module_key": "82bc76354cfef947e06f1cc78f5efe2e", "id_product": 46347, "categories": [ { "id_faq_category": 142, "position": 1, "id_faq": 117, "title": "Questions about payments", "blocks": [ { "id_faq_block": 522, "question": "Will my customers be able to see the PrestaShop Checkout payment method?", "answer": "No, PrestaShop Checkout is the name of the service and the module. Your customers will only see the payment methods they are already familiar with including: credit card, PayPal, and/or another major payment method used in their country.", "version_min": "", "version_max": "" }, ] }, { "id_faq_category": 141, "position": 2, "id_faq": 117, "title": "Questions about refund feature", "blocks": [ { "id_faq_block": 521, "question": "I am trying to issue a refund for a PrestaShop order, but an error message says, “Capture could not be refunded due to insufficient funds.” However, I know I have the funds in my PayPal account.", "answer": "For refunds for an order paid for using a different currency than the ones available on your PayPal account, you have two options:\n\n- Adding all the currencies covered in your store to your PayPal account to avoid rejections of cross-currency transactions and any refund issues.\n\nTo do so, go to paypal.com > Login > Settings > My Money > Currencies management > Add a currency\n\n- Contacting PayPal and asking them to activate the cross-currency refund option. (Via the \"\"Contact us\"\" tab on paypal.com).", "version_min": "", "version_max": "" } ] } ] }