Functioning Mini Cart on Home Page

Hello,

I was able to get the mini cart installed on my home page, but it does not work. Any ideas?

http://myquickfeet.com/

  • Dimitris
    • Support Star

    Hello there Justin,

    hope you're doing good today! :slight_smile:

    Could you please let me know, how exactly did you create this? I mean the mini-cart in homepage, because I see in HTML markup that there are 2 mini-carts and only one is getting updated, before homepage is getting refreshed.

    If you want, you can also surpass this with a bit of CSS, just try to add the following on the very bottom of the Global CSS area:

    #page + #mp-floating-cart {
    z-index: 999;
    }

    Warm regards,

    Dimitris

  • Justin
    • Design Lord, Child of Thor

    Thanks Dimitris, I tried to drop your CSS into the bottom of the Global CSS file with no luck.

    I uploaded the following code to the functions.php file within the theme editor:

    add_filter( 'mp_cart_needed_on_page', '__return_true' );

    add_action( 'init', function() {

    global $post;

    $excluded_pages = array( 12, 34, 56, 78, 99 );

    if( in_array( $post->ID, $excluded_pages ) ) return;

    require_once WP_PLUGIN_DIR . '/marketpress/includes/common/class-mp-product.php';

    require_once WP_PLUGIN_DIR . '/marketpress/includes/common/helpers.php';

    require_once WP_PLUGIN_DIR . '/marketpress/includes/common/class-mp-cart.php';

    $cart = new MP_Cart();

    add_action( 'wp_footer', array( $cart, 'floating_cart_html' ) );

    } );

  • Dimitris
    • Support Star

    Hello Justin :slight_smile:

    Could you please replace above snippet with next one and let us know how that goes please.

    add_filter( 'mp_cart_needed_on_page', '__return_true' );
    add_action( 'init', function() {
    global $post, $cart;

    $excluded_pages = array( 12, 34, 56, 78, 99 );
    if( in_array( $post->ID, $excluded_pages ) ) return;

    require_once WP_PLUGIN_DIR . '/marketpress/includes/common/class-mp-product.php';
    require_once WP_PLUGIN_DIR . '/marketpress/includes/common/helpers.php';
    require_once WP_PLUGIN_DIR . '/marketpress/includes/common/class-mp-cart.php';

    add_action( 'wp_footer', array( $cart, 'floating_cart_html' ) );
    } );

    Warm regards,

    Dimitris

  • Justin
    • Design Lord, Child of Thor

    Thanks Dimitris, I’m getting a new error message. PHP is not my specialty. I have granted support access.

    Your PHP code changes were rolled back due to an error on line 16 of file wp-content/themes/uf-scribe/functions.php. Please fix and try saving again.

    Class ‘Upfront_ChildTheme’ not found

  • Dimitris
    • Support Star

    Hello there Justin

    It seems that you’re editing the functions.php file of UF Scribe, which doesn’t sound too good.

    Have you made any other change in this file?

    If not, then remove above snippet and create a MU plugin instead. Simply create a new PHP file like

    /wp-content/mu-plugins/uf-mp-cart-home.php

    (simply create the /mu-plugins/ folder, if it doesn’t exist)

    and insert the exact snippet in there:

    <?php
    add_filter( 'mp_cart_needed_on_page', '__return_true' );
    add_action( 'init', function() {
    global $post, $cart;

    $excluded_pages = array( 12, 34, 56, 78, 99 );
    if( in_array( $post->ID, $excluded_pages ) ) return;

    require_once WP_PLUGIN_DIR . '/marketpress/includes/common/class-mp-product.php';
    require_once WP_PLUGIN_DIR . '/marketpress/includes/common/helpers.php';
    require_once WP_PLUGIN_DIR . '/marketpress/includes/common/class-mp-cart.php';

    add_action( 'wp_footer', array( $cart, 'floating_cart_html' ) );
    } );

    Warm regards,

    Dimitris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.