问题概述
当将Bookings and Appointments For WooCommerce Premium与 WPML 和 WCML 一起使用时,无法将同一个可预订产品多次添加到购物车。
尝试执行此操作时,会显示以下消息:
“您无法将另一个product name添加到购物车。”
临时解决方法
此问题已在 Bookings and Appointments For WooCommerce Premium 5.3.1 中修复。 更新即可在您的站点上解决此问题,因此只有在您还无法更新时,才需要此临时解决方法。
请在继续操作之前,确保对您的站点进行完整站点备份。
- 将以下代码添加到您主题的 functions.php 文件中。
// WPML Workaround for compsupp-8226 add_filter( 'wcml_add_to_cart_sold_individually', function( $allow, $cart_item_data, $post_id, $qty ) { $product = wc_get_product( $post_id ); if ( $product && 'phive_booking' === $product->get_type() ) { return false; } return $allow; }, 10, 4 );