Marketpress Coupons -- Apply coupon does nothing

While I have been successfully using MarketPress coupons prior to this last Upfront patch, now I do not receive any response when triggering the "Apply Coupon" button. I am able to access global functions such as mp_cart and marketpress.ajaxEvents but not mp_cart.applyCoupon.

There is no event listener registered for the button. I noticed another thread with a similar problem using the "Avada" theme, which I am not using nor familiar with. There are no related console errors nor PHP errors/warnings nor WP errors/warnings.

I have run a plugin test, enabled WP error logging, and neither of these yielded results. This seems to me to an issue with including the appropriate files (like mp_coupons.js) but I do not have extensive knowledge into how Marketpress is loaded. Access has been granted.

  • Adam Czajczyk

    Hello Jeremy,

    I hope you're well today and thank you for your question!

    I just checked MarketPress coupons with the newest Upfront (Parrot theme, just like on your site) and it works fine so it's not a matter of Upfront itself. I noticed however that there's Hummingbird's minification enabled on your site and this is most likely what's affecting that feature.

    That being said, I tried to disable minification for some JS files on your site but so far with no luck. Could you please disable minification entirely, clear all caches (including browser's cache) and test it again?

    If it starts to work then enable minification back, then switch minify and combine options for all files and try enabling them one by one. This may take some time but should let you find a "balanced" settings.

    Keep me informed on this please.

    Best regards,
    Adam

  • Jeremy

    Hello Adam!

    I cleared the caches and disabled browser caching on the Apache server. I disabled minification and concatenation entirely. I was left with a few console errors related to inclusion order: colorbox.js (a jQuery plugin required by MP) and mp-select2 (another jQuery plugin and MP-frontend dependency). This resolved all console errors, yet the apply button has no effect and the mp_cart.applyCoupon function is not accessible.

    Additionally, this problem began before I configured hummingbird. I appreciate your help and look forward to solving this problem!

    Thanks,
    Jeremy

  • Dimitris

    Hey there Jeremy,

    I hope you're doing really well and don't mind skipping in! :slight_smile:

    I cleared the caches and disabled browser caching on the Apache server. I disabled minification and concatenation entirely. I was left with a few console errors related to inclusion order: colorbox.js (a jQuery plugin required by MP) and mp-select2 (another jQuery plugin and MP-frontend dependency). This resolved all console errors, yet the apply button has no effect and the mp_cart.applyCoupon function is not accessible.

    I just inspected your site and I noticed that you have changed the position of some styles and scripts under Hummingbird -> Minification. Can you please try to revert all of these into the original position and re-test the coupon functionality?

    Additionally, this problem began before I configured hummingbird.

    Well, this may cancel my previous statement, but please do proceed with the reversion I mentioned to see how this goes. :slight_smile:
    Did you make any changes prior to Hummingbird that may have caused this misbehavior? If you can't recall what changes have been made, you can always perform a plugin conflict test. You can find a detailed flowchart in https://premium.wpmudev.org/manuals/using-wpmu-dev/getting-support/
    (you may have to scroll down a bit)

    I look forward for your results!

    Warm regards,
    Dimitris

  • Dimitris

    Hello Jeremy,

    I can still observe that there are styles and scripts not positioned in their original position and /wp-content/plugins/marketpress/includes/addons/mp-coupons/ui/js/mp-coupons.js is both minified and combined.

    Can you please exclude this file from minification and combination, and also revert all styles and scripts to load at their original location?
    Please do proceed with these changes and test again your coupons functionalities.
    I look forward for our results! :slight_smile:

    Kind regards,
    Dimitris

  • Jeremy

    Curious that the coupon.js ended up down there! I suppose it may have been removed and re-added when I attempting disabling and reenabling the plugin.

    First, I turned off minification and concatenation for coupon. This did nothing.

    Next, I reverted all includes back to their original position. This broke the site with the aforementioned errors (colorbox and mp-select). These errors are resolved by placing colorbox and mp-select in the head as well as mp-cart and mp-frontend in the tail. Since these are MP dependencies, it seems to me that there is something wrong with how marketpress is loading its dependencies. The coupon button still fails to do anything.

    I have already tried a plugin test, unfortunately without result.

    Thanks for your help! This is really important to me, so I appreciate the assistance.
    ~Jeremy

  • Jeremy

    I have added the mp-coupons.js to a mu-plugins .php file, though now I get a fatal PHP error on line 784 of marketpress.php. It reads as follows:

    require_once $this->plugin_dir( 'includes/addons/class-mp-addons.php' );

    Indeed, this file is missing. Instead, I only have a class-mp-addons-list-table.php in that location. If I change the require_once to point to this file, I get the following error:

    Fatal error: Class 'MP_Addons' not found in /var/www/betterbetterbetter.org/public_html/wp-content/plugins/marketpress/includes/common/helpers.php on line 1096

    This block is as follows:

    if ( ! function_exists( 'mp_register_addon' ) ) :
    
    	/**
    	 * Wrapper function for MP_Addons::register()
    	 *
    	 * @since 3.0
    	 *
    	 * <a title="@param" href="/profile/param">param</a> array $args
    	 */
    	function mp_register_addon( $args = array() ) {
    		MP_Addons::get_instance()->register( $args );
    	}
    
    endif;

    MP_Addons seems to be declared in my missing file, since the only other place I can find this class is in the class-mp-addons-list-table.php as MP_Addons_List_Table. Perhaps you could post this file for me so I can add it to my installation?

    Thanks,
    Jeremy

  • Jeremy

    I apologize for my frequent comments, but this is mission-critical for a several thousand dollar project in the works and I have but a day to get these coupons in order (in the least hacky way possible).

    While keeping the mp_coupons.js in the mu-plugins development with a timeout, I can apply coupons successfully. The issue now is that the CSS is not loading (corrected simply by changing my marketpress-style, but indicative of a loading problem) and a console error when I attempt to remove the coupons already applied (mp_coupons/mp_coupons_il8n not found). If I require_once('marketpress/includes/addons/mp-coupons/class-mp-coupon.php'), I get fewer console errors, but it seems that the ajax request to remove the coupon still fails.

    I am certain that all of these issues would be ameliorated if it were loading properly and with all of the files. If you could look into this, I would deeply appreciate it. Attached is the file I have to get it working thus far.

    Thanks,
    Jeremy

  • Predrag Dubajic

    Hi Jeremy,

    I tried disabling MP on your site to check out few things as I was unable to replicate the issue on my installation no matter what I tried, do you have any additional coding added that could be causing this?

    Could you provide me with your FTP or cPanel login details so we can get your site back online asap?
    You can send us your details using our contact form https://premium.wpmudev.org/contact/ and the template below:

    IMPORTANT: Make sure you select "I have a different question" for your topic so it doesn't go back to forums - this and the subject line ensure that it gets assigned to me.

    Subject: "Attn: Predrag Dubajic"
    - Site login url
    - WordPress admin username
    - WordPress admin password
    - FTP credentials (host/username/password)
    - cPanel credentials (host/username/password)
    - Link back to this thread for reference
    - Any other relevant urls

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.