Shopping Cart Cookie / Variables

Hello,

I am creating a custom theme and I have a need to access the shopping cart variables.

For instance, I need to know exactly 2 things.
* How many items are in the cart (already got that via mp_items_count_in_cart())
* What total dollar amount is in the cart (can't find this)

How can I find out via PHP or JS (or both) what the total dollar amount in the shopping cart is.

Thanks.

Jay
CompuMatter

  • Jay

    I would like to say that my purpose here is as follows.

    I am using the MP cart within a company website. It is not 'just a store' but a store within a company site.

    It is possible that a client will reroute back to the home page or any page other than the Store page. In that case, I see the mini-cart is programmed to not appear. I need to the mini-cart to appear as long as it detects there is something in the cart.

    That is the functionality I need.

    Thanks.

    Jay
    CompuMatter

  • Jay

    I am supporting myself but making progress :slight_smile:

    I noticed in the file class-mp-cart.php in the function floating_cart_html() if I change:
    $cart_needed = apply_filters( 'mp_cart_needed_on_page', false ) to
    $cart_needed = apply_filters( 'mp_cart_needed_on_page', true )

    The cart displays on every page.... even if there is nothing in it. However, that seems on the right track.

    Still looking for a dev to promote a suggestion for the behavior desired as noted in my previous post.

    Jay

  • Luís

    Hi @amazon,

    Hope you're doing well today!

    Regarding to your first question:

    What total dollar amount is in the cart (can't find this)

    have you tried the product_total function of marketpress/includes/common/class-mp-cart.php?

    If I understood well your question, you need to show the minicart in all pages, if there is something in the cart? Right?

    I wil ping the developer to get more information.

    Cheers, Luís

  • Jay

    Luis,

    Yes that is correct, "I need to show the minicart in all pages, if there is something in the cart"

    When you think about it, that should be the default behavior no matter what page you're on. However, if I navigate outside the /store directory, the cart disappears.

    Last night I discovered where the failure is located. It is the variable called $cart_needed.

    On line #1207 of /includes/common/class-mp-cart.php if I change:
    $cart_needed = apply_filters( 'mp_cart_needed_on_page', false );
    to
    $cart_needed = apply_filters( 'mp_cart_needed_on_page', true);

    The cart remains visible. However that is a core code change. I have tried overriding in within my functions.php to no avail since $cart_needed is a local variable.

    If your dev can provide a core happy method of setting that to 'true' this will resolve that part of my problem.

    I look forward to hearing from your dev on this.

    Jay

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.