php - 可持续地覆盖/禁用 WooCommerce/Wordpress 核心功能 (PayPal IPN)
问题描述
基本上我们有一个相当复杂的工作流程,为了节省时间,我宁愿不做太多细节。我得出的结论是,我们需要禁用 PayPal IPN 处理程序中的金额验证,因为它会破坏我们使用的订单状态的自定义工作流程。
有问题的代码
$this->validate_amount( $order, $posted['mc_gross'] );
在第 195 行,解决它的“直截了当”/“head trough the wall”的方法是我显然可以进入插件编辑器并注释掉那段代码,这将解决我们遇到的问题,但显然这不是一个非常有用的解决方案,因为每次 WooCommerce 更新时它都会被覆盖
这是调用的函数:
/**
* Check payment amount from IPN matches the order.
*
* @param WC_Order $order Order object.
* @param int $amount Amount to validate.
*/
protected function validate_amount( $order, $amount ) {
if ( number_format( $order->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
WC_Gateway_Paypal::log( 'Payment error: Amounts do not match (gross ' . $amount . ')' );
/* translators: %s: Amount. */
$order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'woocommerce' ), $amount ) );
exit;
}
}
从第 148 行开始。基本上我想禁用订单状态更新。我对 PHP 或 Wordpress 的了解都不够,甚至不知道在谷歌搜索时要寻找什么,因为我完全来自不同的语言,只是偶然发现了这一点。我可以覆盖/覆盖该函数以更改其在例如functions.php中的行为,或者什么是“正确”的方法来解决这个问题,而不必继承和自定义整个网关作为一个全新的东西?
解决方案
推荐阅读
- android - 如何在 Android 中将背景设置为 MenuItem onPrepareMenuOptions
- jquery - 使用jQuery隐藏表格中显示的所有子元素
- java - 为什么三元表达式在 if 语句工作正常时不更新值?
- google-cloud-platform - 如何安全地使用 Google Speech-to-Text API?
- php - 如何打印这个图案?嵌套循环不起作用
- java - 执行批处理不更新 SQL 表中的数据 -
- html - Thymeleaf:连接表达式
- ruby-on-rails - 带有 XML 正文的 HTTP 200 的 API 响应
- ruby - sinatra activerecord 在heroku 上找不到模型
- javascript - 使用过滤器按钮从黑白到彩色的组合图像