• Resolved Hesham Saad

    (@heshamsaad)


    Hello, I have enabled “Should it be possible to have more than one donation product in the cart at the same time?” option and all are working but the mini-cart displays the product price instead of the donation amount.

    Any chance to modify it?

    Thanks

    • This topic was modified 11 months, 3 weeks ago by Hesham Saad.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Hesham Saad

    (@heshamsaad)

    I have figured it out and here are the solution and it working for me

    /**
     * Modifies the price displayed in the mini cart for a WooCommerce cart item.
     *
     * @param string $price The original price of the cart item.
     * @param array $cart_item The cart item data.
     * @param string $cart_item_key The cart item key.
     * @return string The modified price to be displayed in the mini cart.
     */
    
    function wcdp_modify_mini_cart_product_price($price, $cart_item, $cart_item_key) {
    
        if (isset($cart_item['wcdp_donation_amount'])) {
            $donation_amount = $cart_item['wcdp_donation_amount'];
            $price = wc_price($donation_amount);
        }
        return $price;
    }
    
    add_filter('woocommerce_cart_item_price', 'wcdp_modify_mini_cart_product_price', 100, 3);

    Hello, brother Hisham I am looking for a way to add an “add to cart” button after choosing the donation value from the available amount donatin How can i do that?

    thanks

    Plugin Author Jonas

    (@flinnn)

    Hi heshamsaad,

    nice to see that you found a solution to your first question.
    Your second question is a bit more complicated but already on my roadmap. At this time I cannot give you a timeline yet on when this will be implemented.

    Best,
    Jonas

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘mini-cart donation amount issue’ is closed to new replies.