[MarketPress eCommerce] Marketpress – How can I retrieve the coupon code used?

I need some help retrieving coupon codes from an order. We’re using coupon codes and they’re working just fine…functionally there are no issues.

However, I’ve having great difficulty with figuring out how to display the coupon code that was used, on the Order Status page. The code used is shown on the Cart, Checkout, and Admin/Edit screens but not on Order Status. And somehow I can’t figure this out.

The item sold is a download link and in /plugins/marketpress/common/class-mp-order.php we added a 2nd link to an extra info page. I want to append the coupon code used to that URL…so something like the following (replacing the TEST123 with the dynamic coupon code):

echo '<a href=“/my_custom_page.php?coupon=TEST123” target="_blank">View Coupon Details</a>';

Most of what I’ve found takes the coupon code as a parameter, but that’s the value I want to get back. I can’t seem to even find where the coupon is retrieved for the screens where I see it displayed. Any ideas or examples to help point me in the right direction?

Thanks in advance!

WordPress: Version 4.9.4
Marketpress: Version 3.2.8
Theme: bFastMag Pro: Version 2.0.0

  • Katya Tsihotska
    • Ex Staff

    Hi jenn

    Hope you’re having a wonderful day!

    Since this is dealing with more advanced coding topics, I’m going to ping our SLS Team (code experts) to get their valuable feedback on this question. One of our SLS members will reply back here as soon as more information is available.

    Please keep in mind that our SLS Team deals with more complicated issues, thus it may take a little longer for them to reply here. Thank you for your patience while we look into this further.

    Kind regards,

    Katya

  • jenn
    • Design Lord, Child of Thor

    Hi Katya,

    This is for the front-end to display for the user. The coupon code entered is shown on the cart after entered, and also all the way through checkout ( as seen in screenshot as “TESTITNOW” ) , but not on the final Order Status page after they’ve paid, which is where I want to add it.

    I figured there would be something I could simply copy & paste from one place to the other but I haven’t been able to find it or iterate through coupons to grab it. Even just putting it in a session variable would be fine as multiple codes wouldn’t be used or added and removed.

    Thanks!

  • jenn
    • Design Lord, Child of Thor

    Perhaps for others’ reference, here’s how I got the code used:

    if ( $coupons = $this->get_meta( 'mp_discount_info' ) ) {
    foreach ( $coupons as $code => $discount ) {
    echo $code; //displays "TESTITNOW"
    }
    }