我需要根据 WooCommerce 感谢页面上的付款方式打印不同的消息。
我正在使用下面的代码,但它使我的网站崩溃并显示以下错误:
致命错误:未捕获的错误:调用 int 上的成员函数 get_payment_method()...
add_action( 'woocommerce_thankyou', 'bbloomer_add_content_thankyou' );
function bbloomer_add_content_thankyou($order) {
if( 'bacs' == $order->get_payment_method() ) {
echo '<h2 class="h2thanks">Get 20% off</h2><p class="pthanks">Thank you for making this purchase! Come back and use the code "<strong>Back4More</strong>" to receive a 20% discount on your next purchase!</p>';
}
else{
echo '<h2 class="h2thanks">Get 100% off</h2><p class="pthanks">Thank you for making this purchase! Come back and use the code "<strong>Back4More</strong>" to receive a 20% discount on your next purchase!</p>';
}
}
谁能告诉我哪里出了问题?