简体   繁体   English

在WooCommerce中为每个支付方式添加一个单独的支付按钮

[英]add a separate payment button for each payment method in WooCommerce

I want to add a separate payment button for each payment method in WooCommerce.I designed checkout page using cart flows我想为 WooCommerce 中的每种付款方式添加一个单独的付款按钮。我使用购物车流程设计了结帐页面

I tried in chrome developers tool by copying button html content and place in every div of payment methods but that was just temporarily changes.. I then go to plugin files editor and select cart flows plugin but don't know what's to do next我通过复制按钮 html 内容并放置在付款方式的每个 div 中尝试在 chrome 开发人员工具中,但这只是暂时更改。然后我 go 到插件文件编辑器和 select 购物车流程插件但不知道下一步该做什么

You should consider modifying the template files..您应该考虑修改模板文件..

  1. Locate the WooCommerce template files:找到 WooCommerce 模板文件:

You can find the template files in the "wp-content/plugins/woocommerce/templates" directory.您可以在“wp-content/plugins/woocommerce/templates”目录中找到模板文件。

  1. Copy the "checkout/payment.php" file:复制“checkout/payment.php”文件:

Make a backup of the original file and then copy the "payment.php" file to your theme directory.备份原始文件,然后将“payment.php”文件复制到您的主题目录。

  1. Edit the copied file:编辑复制的文件:

In the copied file, look for the section that displays the payment methods and modify it to add separate buttons for each payment method.在复制的文件中,查找显示付款方式的部分并对其进行修改,为每种付款方式添加单独的按钮。

Example code (That's an old woocommerce version I found in my computer and edited it):示例代码(这是我在计算机中找到并编辑的旧 woocommerce 版本):

<input type="radio" id="payment_method_<?php echo esc_attr( $gateway->id ); ?>" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php checked( $gateway->chosen, true ); ?> />

<label for="payment_method_<?php echo esc_attr( $gateway->id ); ?>">
    <?php echo wp_kses_post( $gateway->get_title() ); ?> <?php echo wp_kses_post( $gateway->get_icon() ); ?>
</label>

<div class="payment_box payment_method_<?php echo esc_attr( $gateway->id ); ?>" <?php if ( ! $gateway->chosen ) : ?>style="display:none;"<?php endif; ?>>
    <?php $gateway->payment_fields(); ?>
</div>

Save and upload the file:保存并上传文件:

Save the changes and upload the edited file to your theme directory.保存更改并将编辑后的文件上传到您的主题目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM