Replace Qty in cart for Bookable Product at the backend with persons for all subsequent actions

梦想与她 提交于 2020-06-17 09:42:16

问题


I am using the following code to replaced the quantity column in cart with persons for bookable products (i am using WooCommerce Bookings plugin). However, it only changes the cart Qty in the front end but other actions like shipping costs / cart fees set based on qty in cart is not getting updated. Can i add some more code to the above to even replace the qty with persons at the backend for other operations like shipping cost and cart fees.

function replace_cart_quantity_for_bookings( $quantity, $cart_item_key, $cart_item ){
    // Only for bookable product items
    if( isset($cart_item['booking']) && isset($cart_item['booking']['_qty']) ){
        $quantity  = '<span style="text-align:center; display:inline-block; line-height:10px">'.$cart_item['booking']['_qty'].'<br>
        <small>(' . __('persons','woocommerce') . ')</small><span>';
    }

    return $quantity;
}

来源:https://stackoverflow.com/questions/61852727/replace-qty-in-cart-for-bookable-product-at-the-backend-with-persons-for-all-sub

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!