We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
读取支付方式下面的Checkout动态显示?
Checkout
$className = '\\Plugin\\' . Str::studly($item->code) . '\\Checkout'; if (class_exists($className)) { $object = app($className); if (method_exists($object, 'isEnable')) { $plugin->setEnabled($object->isEnable()); } }
The text was updated successfully, but these errors were encountered:
不需要这样,写个插件就解决了。
后台配置:
$mappers = $options = []; $currencies = currencies(); foreach (CountryRepo::getInstance()->getCountries() as $country) { $options[] = [ 'value' => $country->id, 'label' => $country->name, ]; } $billingMethods = PluginRepo::getInstance()->getBillingMethods(); foreach ($billingMethods as $method) { $plugin = $method->plugin; $mappers[] = [ 'name' => $plugin->code, 'label' => $plugin->name['zh_cn'] ?? $plugin->code, 'type' => 'select', 'options' => $options, 'required' => true, 'rules' => 'required', 'emptyOption' => false, ]; } return $mappers;
启动文件核心代码
class Boot { /** * @return void * @throws Throwable */ public function init(): void { listen_hook_filter('service.checkout.billing.methods', function ($data) { foreach ($data as $index => $item) { if (! PaymentFilterService::getInstance($item['code'])->checkValid()) { unset($data[$index]); } } return array_values($data); }); } }
判断是否可用核心代码
public function checkValid(): bool { $countryID = plugin_setting('pay_filter', $this->billingCode, false); $address = CheckoutService::getInstance()->getShippingAddress(); if (empty($countryID)) { return false; } if (empty($address)) { return false; } return $countryID == $address['country_id'] ?? 0; }
Sorry, something went wrong.
No branches or pull requests
读取支付方式下面的
Checkout
动态显示?The text was updated successfully, but these errors were encountered: