问题描述
我正在尝试在 Klarna 支付插件中添加通讯复选框。 这是实际网站的屏幕截图。
这是实时链接:https://stressleksaker.se/checkout/ 这是插件代码:https://github.com/krokedil/klarna-checkout-for-woocommerce
我想在条款和条件复选框下方添加时事通讯,但我很难,因为此布局是由 klarna 插件生成的。
/**
* Echoes Klarna Checkout iframe snippet.
*/
function kco_wc_show_snippet() {
$klarna_order = kco_create_or_update_order();
do_action( 'kco_wc_show_snippet',$klarna_order );
echo $klarna_order['html_snippet'];
// PHPcs:ignore wordpress -- Can not escape this,since its the iframe snippet.
}
这里是 kco_create_or_update_order 函数定义。
function kco_create_or_update_order( $order_id = null ) {
// Need to calculate these here,because WooCommerce hasn't done it yet.
WC()->cart->calculate_fees();
WC()->cart->calculate_shipping();
WC()->cart->calculate_totals();
if ( WC()->session->get( 'kco_wc_order_id' ) ) { // Check if we have an order id.
// Try to update the order,if it fails try to create new order.
$klarna_order = KCO_WC()->api->update_klarna_order( WC()->session->get( 'kco_wc_order_id' ),null,true );
if ( ! $klarna_order ) {
// If update order Failed try to create new order.
$klarna_order = KCO_WC()->api->create_klarna_order();
if ( ! $klarna_order ) {
// If Failed then bail.
return;
}
WC()->session->set( 'kco_wc_order_id',$klarna_order['order_id'] );
return $klarna_order;
}
return $klarna_order;
} else {
// Create new order,since we dont have one.
$klarna_order = KCO_WC()->api->create_klarna_order();
if ( ! $klarna_order ) {
return;
}
WC()->session->set( 'kco_wc_order_id',$klarna_order['order_id'] );
return $klarna_order;
}
}
我已尝试使用 kco_wc_show_snippet
钩子来显示,但它显示的是 Iframe 之前的内容,但我想在 Iframe 内的条款和条件复选框下方显示时事通讯复选框。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)