Pull in discounted Appointments+ price to google calendar

Hi,

I have some code from Panos which is now working great so that when an customer books an appointment using a coupon code the correct discounted price shows in a confirmation email. As noted in this thread

https://premium.wpmudev.org/forums/topic/help-needed-with-coupon-codes-and-appointments-integration

But I'd like it to also pull this discounted price into the Google Calendar via a shortcode. Ideally if no coupon code is used then only the full price is displayed. Or a N/A for the Discounted Price would be acceptable.

Hope someone can help

Kind Regards
Kieran

  • Panos
    • SLS

    Hi Kieran ,

    I have changed the custom plugin again so it could handle both situations:

    1. Include the discount price in the notification email

    2. Include the discount price in the gCal description

    The problem is that the plugin I had provided you previously could not be used for the gCal info, so it had to be rewritten differently, and that's why I'm afraid will have to change the text again...

    I have it attached here so you can download it and replace the one you have already.

    Then make some tests and check the notification messages and the gCal description.

    If all is OK edit the text of each message. For the gCal description edit line 146 of the plugin where it says
    $data .= 'Discounted price: ' . $discount_price;
    and for the notification message edit line 175 where it should say:
    $replacement['/(?:^|\b)wpmudev_price_with_coupon_list(?:\b|$)/'] = 'Discount price: ' . $discount_price;

    Thanks!
    Panos

  • Kieran
    • The Crimson Coder

    Hi Panos

    Sorry I get this error message

    Fatal error: Cannot redeclare wpmudev_add_notifications_replacements() (previously declared in /var/sites/t/treatmeathome.com/public_html/wp-content/mu-plugins/wpmudev_apps_n_mp_couponprice_in_msg.php:160) in /var/sites/t/treatmeathome.com/public_html/wp-content/plugins/wpmudev_apps_n_mp_couponprice_in_msg/wpmudev_apps_n_mp_couponprice_in_msg.php on line 49

  • Rupok
    • Support Ninja

    Hi Kieran, hope you had a wonderful day.

    From the error, it seems like you have two files declaring same function. One is here:
    treatmeathome.com/public_html/wp-content/mu-plugins/wpmudev_apps_n_mp_couponprice_in_msg.php
    And another is here:
    treatmeathome.com/public_html/wp-content/plugins/wpmudev_apps_n_mp_couponprice_in_msg/wpmudev_apps_n_mp_couponprice_in_msg.php

    So for solving this, can you please follow the steps below?

    # Please login to your server with any FTP application
    # Go to "/public_html/wp-content/mu-plugins" folder
    # Rename the "wpmudev_apps_n_mp_couponprice_in_msg.php" file to "wpmudev_apps_n_mp_couponprice_in_msg.php.BAK"
    # Then go to this folder "/public_html/wp-content/plugins/wpmudev_apps_n_mp_couponprice_in_msg"
    # Move the file "wpmudev_apps_n_mp_couponprice_in_msg.php" to here "/public_html/wp-content/mu-plugins".

    If it seems too complex for you, Can you send me message with FTP access credentials through our secure contact form here: https://premium.wpmudev.org/contact/ so we can do this on behalf of you?

    Subject: "Attn: Rupok"
    - FTP Username
    - FTP Password
    - FTP Host
    - Link back to this thread for reference
    - Any other relevant URLs

    Select "I have a different question" for your topic. This and the subject line ensure that it gets assigned to me.

    Please let us know here when you are done sending. We will be glad to help further.

    Have a nice day. Cheers!
    Rupok

  • Kieran
    • The Crimson Coder

    Hi Rupok

    thanks for pointing that out. Whoops I've deactivated the old plugin and installed the new one as an MU Plugin.

    Panos - Unfortunately it's not working. I'm neither receiving a discounted price email or google discounted price? I've put "wpmudev_price_with_coupon_list" in the confirmation email and google calendar settings?

    Kind Regards
    Kieran

  • Panos
    • SLS

    Hey @kieran!

    I just remembered that I didn't inform you that you need to deactivate and re-activate it as on activation it creates a custom table in db. Perhaps this is the reason it is not working for you.

    So could you please reactivate it and let me know if it works?

    Also, in the gCal description I am not replacing any description macro code, it's just being added harcoded. I could change that so it does replace a specific makro, but first would like to make it work :slight_smile:

    Thanks!
    Panos

  • Kieran
    • The Crimson Coder

    Hi Panos

    I've made this a regular plugin now and activated and deactivated then reactivated again. I got an error message

    The plugin generated 2 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

    However it activated.

    I got to my home page however and get this message.

    "Warning: Cannot modify header information - headers already sent by (output started at /var/sites/t/treatmeathome.com/public_html/wp-content/plugins/wpmudev_apps_n_mp_couponprice_in_msg/wpmudev_apps_n_mp_couponprice_in_msg.php:209) in /var/sites/t/treatmeathome.com/public_html/wp-includes/pluggable.php on line 1167"

    So I deactivated the plugin and then made it an MU Plugin. The above error went away but unfortunatly the discounted price wasn't pulled through in emails.

    Support is open as usual :slight_smile: I've not deactivated the MU Plugin and normal plugin

    Kind Regards
    Kieran

  • Panos
    • SLS

    Hi Kieran ,

    I don't know how I missed this :disappointed:

    Really sorry for the delay here!

    I'm not sure if previous ftp is valid, but I did several tests on my test sites and seems that the snipped here works fine:
    https://gist.github.com/panoslyrakis/42095af56986221eb32c8ae94747a114

    You can donwload the zip, unzip it and upload it to your mu-plugins or plugins folder (if you upload it in your plugins folder you will also need to activate plugins).

    Please let me know how it goes.

    Thanks!

  • Kieran
    • The Crimson Coder

    Hi Panos,

    That's nearly there. One minor adjustment please

    My notes section looks like this

    Client Name. xx
    Price: 45
    Service Provider : John SmithDiscounted
    Price: 40.50
    Appointment Price: 45
    Coupon used: EMA10
    Discounted price: 40.50

    It needs a <enter> so that my Discounted Price appers on the next line? Also the price is appearing twice because I'm using the placeholder PRICE. If I don't use this placeholder then when a customer doesn't use a coupon code I don't see the price at all in my calendar as your code doesn't activate!

    Is it possible to get your code to replace the current placeholder "PRICE" or just create a new Placeholder called "COUPON PRICE" which shows the coupon used and discounted price. It would only shows if a coupon has been used. By being a placeholder the user can control where in which order it appears in the notes section too.

    That would be the perfect solution I think

    Additionally I've reactivate the confirmation email plugin (linked it original question above) and it seems to be working ok again although it was causing me an issue before. So now we are close to having discounted price in both confirmation email and calendar. I have faith you can get us there!

    It is also possible we can get that discounted price now pulled through into the back end of the Appointments plugin. So that when I export the Appointments it tells me which appointments have had a discount? I do my accounts by exporting all appointments but I cant see the discounts? I think I made a seperate thread for it and have included an altered screen shot of what I mean

    Kind Regards
    Kieran

  • Kieran
    • The Crimson Coder

    Hi Panos

    I've had a quick think. Can we keep it simple with maybe 3 placeholders

    PRICE: Price
    COUPON CODE: Coupon Code
    DISCOUNTED PRICE: Discounted Price

    The spacing just needs to ensure that each placeholder starts on a new line as it does now?

    Coupon code and discounted price only appear if a coupon has been used otherwise the whole line doesn't show. If this isn't possible then just let them show N/A

    What you displayed above would work too for a DISCOUNTED PRICE placeholder. Just not sure everyone would want to see the coupon code too. Might be best as a seperate placeholder but can go with your suggestion if mine is too much work.

    Thanks
    Kieran

  • Kieran
    • The Crimson Coder

    Great thanks Panos I'll test it later. Will theses placeholders work in confirmation emails too like in the original thread link?

    That would be awesome I think you could integrate that into main plugin then.

    Will test it later I'm just out at the minute :slight_smile:

  • Kieran
    • The Crimson Coder

    Hi Panos,

    I've tried the placeholders in my calendar

    Price: PRICE
    Coupon Code: COUPON_CODE
    Discounted Price: DISCOUNTED_PRICE

    But only price is working for me? :slight_frown: Sorry can you take another look please. Do you think you can alter the code here too

    https://premium.wpmudev.org/forums/topic/help-needed-with-coupon-codes-and-appointments-integration

    so it works in confirmation/reminder emails too please :slight_smile: It's not working in Appointments Version 2.0.4 and would be better with the new placeholders anyway.

    Many Thanks
    Kieran

    P.S It would make sense it doesn't say the text too so it's consistent with the other placeholders?

  • Kieran
    • The Crimson Coder

    Actually I see why you've got it to add the text because then it wont display the text if there is no discount. ok I understand now. Let's leave it like that! I'd like to get this in the main plugin once working so just might need to make sure the help file is clear for folks

  • Nithin
    • Support Wizard

    Hi Kieran,

    I'd like to get this in the main plugin once working so just might need to make sure the help file is clear for folks

    I checked this with the dev, and if you meant by main plugin the Appointments+ plugin, then the customization provided in this thread is more specific to your needs, and according to your system. At the moment there isn't any plans to implement in the Appointments+ plugin.

    If you are still looking to include this as a feature, would recommend you to create a new feature request, so that more members who +1s the request, the more it'll be considered for development.

    Please follow this link to create a new thread for feature request:
    https://premium.wpmudev.org/forums/#question

    Best Regards,
    Nithin

  • Kieran
    • The Crimson Coder

    Hi NIthan

    At the minute the standalone version of Appointments does not work with Marketpress and voucher codes. This surely is a core feature!

    My customers can't book using vouchers codes as the core Appointments+ product can't send a confirmation email out containing the discounted price, no can it send that discounted price to the google calendar, nor can it show the discounted price in the appointments back end.

    If those features aren't useful for everyone not just me that I don't know what is!

    When was the last time Appointments+ actually upgraded, not including bug fixes! It's not been upgraded in ages and when I suggest a feature which would be useful for nearly everyone it's rejected.

    There's no point me posting in the features forum cos you've not implemented any upgrade to Appointments at all never mind just mine.

    I must say I'm getting really frustrated with the lack of love WPMU DEV show Appointments+! It could be a market leader with a bit more support. It's the only reason If subscribe if I'm honest

    Kieran

  • Nithin
    • Support Wizard

    Hi Kieran,

    Hope you are doing good today. :slight_smile:

    I do understand you, and I have passed your views to the developer, and the good news is that, we will be implementing this in the future release of Appointments+. :slight_smile:

    Since it's a new feature, we will be testing this extensively, but at the moment, I don't have an exact ETA on when we will be pushing this live in the Appointments+ plugin, will keep you updated once we are ready with the live version.

    Have a nice weekend ahead. :slight_smile:

    Best Regards,
    Nithin

  • Panos
    • SLS

    Hi Kieran,

    Can I just point out the solution provided by Panos is not working for me though

    It is working fine in my tests, only case it doesn't work is when Stripe is used in checkout page. I assume you are using stripe too.

    If this is the case I will have a closer look on what is going on and not adding coupon information with stripe.

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.