Changing “Post” and “Detail” information

Hi guys,

We’d like to alter the information displayed by the “Detailed Referral Overview” shortcode [affiliates_affiliate_stats type=”stats-referrals” data=”message” show_pending=”true” /]

However, we’re not too sure how to do that. For example, the “post” column is populated by links with wrong URLs so they forward the user to nothing : Protected: Order – January 7, 2016 @ 02:55 PM —-> http://nationhats.staging.wpengine.com/?post_type=shop_order&p=12020

Would it be possible to have the actual links to the products that originated the referral instead of these weird ?

How exactly does the “message” key works in the Details column?

How complex would it be to add meaningful information to some actions?

For example, if it’s a direct sale, then we could add “Direct sale”, if it’s a sale from an referred affiliate it could be “Level 1/2/3/XYZ Sale”, if it’s a form submitted “New affiliate application”, etc.

Thank you!

Regards,
B

10 Responses to Changing “Post” and “Detail” information

  1. Bastien January 16, 2016 at 2:10 pm #

    Good morning Kento,

    Alright sounds good, thank you for all. If needs be, I submitted a thread with some more details about the modifications I made on a few files to add more information on the stats shortcode. The thread is “Differentiate different “Sale” referrals”

    Looking forward to test out the new shortcode!

    Thank you again.

    Kind regards,
    B

    • Kento January 18, 2016 at 10:00 am #

      Hi Bastien,

      I’ll review the Banners suggestions, instead of hacking the code I’d rather suggest we add filters there, too if needed.

      Cheers

  2. Kento January 16, 2016 at 1:30 pm #

    Hi guys,

    I’m adding some filters to the shortcode which will make this whole thing a lot easier for you Bastien. It will basically allow you to modify the columns displayed and also add new ones as needed. I’ll provide an example plugin which uses these filters shortly and the modifications will be available in the upcoming release (which is being prepared right now).

    Cheers

  3. Bastien January 13, 2016 at 9:00 pm #

    Hello George,

    Just wanted to share with you guys my improved version of the Affiliate_Stats shortcode. I didn’t figure out how the “Details” column worked (the data parameter with the “message” key) as the “IXAP—” naming makes it difficult to follow the code.

    Nevertheless, I made the “Post” column more clever (now renamed to Details, Details was renamed to “Other” and isn’t used anyway), I added a conditional to check for the [type] key, which is exactly what I wanted to differentiate the different referrals origin.


    if ( $IXAP201 ) {
    if ( !empty( $IXAP15->post_id ) && ($IXAP15->type == 'product' ) ) {
    //$IXAP211 = get_permalink( $IXAP15->post_id );
    //$post_title = get_the_title( $IXAP15->post_id );
    //$IXAP62 .= '' . wp_filter_nohtml_kses( $post_title ) . ''.''.print_r($IXAP15, TRUE).'' . '';
    $a_product = preg_replace('@\(.*?\)@', '', $IXAP15->description);
    $IXAP62 .= 'You just sold a product : ' . $a_product . '';
    } elseif ( !empty( $IXAP15->post_id ) && ($IXAP15->type == 'sale') ) {
    $IXAP62 .= 'You referred a sale : ' . $IXAP15->description . '';
    } elseif ( empty( $IXAP15->post_id ) && ($IXAP15->type == 'user') ) {
    $a_data = explode(" ", $IXAP15->description);
    $IXAP62 .= 'New user permanently linked to your account : ' . $a_data[count($a_data)-1] . '';
    } elseif ( empty( $IXAP15->post_id ) && ($IXAP15->type == 'manual') ) {
    $IXAP62 .= 'Manual Transaction : ' . $IXAP15->description . '';
    } else {
    $IXAP62 .= 'N/A';
    }
    }

    There are surely scenarios I haven’t covered yet (for example, a referral originating from an associated user or a referral originating from a Formidable form submission) but it’s a good start. I removed entirely the display of a link because it returned a link to an order post_type, which is protected and not available to the public (so it has no value).

    Moreover, it would make sense to make the strings editable/translatable so we’d have to add these options in the plugin settings.

    My next step would be to integrate the order details below each sale type of referrals. It might be achievable without any additional jquery script.

    I guess this would close this thread. I’ll make sure to update you guys here when and if I update the shortcode to add the order details and meta information.

    Thank you for all your help!

    Kind regards,
    B

  4. Bastien January 12, 2016 at 11:35 pm #

    Found the culprit!

    These two lines caused some problem :


    $item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
    $item_meta->display();

    I commented them out as the meta output seems to break HTML. I also added a conditional to skip the empty orders :


    foreach( $referrals as $referral ) {
    $order_id = $referral->post_id;
    $order = new WC_Order( $order_id );
    if ( $order_id ) { ... }
    }

    ——

    Trying to improve [affiliates_affiliate_stats] I figured it would require quite a lot of modification to get to where we want. It would be great if there was a shortcode to display a table between Stats and WooCommerce_Orders. Two separate tables are not a good UI.

    The best way to merge both tables would be to implement a “+/-” on each row that we could click on to unfold the order details/meta. Since that involves jQuery that falls a bit outside of my set of skills unfortunately. I’ll try to hire someone to develop that but you could put a note somewhere to streamline the affiliates stats.

    ——

    About the “message” key (the Details column), how can we add information here?

  5. Bastien January 12, 2016 at 9:37 pm #

    Note : I also see a few lines with an “Order #0”, that’s probably referrals that are NOT from an order (i.e : a formidable form).

    Shouldn’t these lines be skipped?

    Regards,
    B

  6. Bastien January 12, 2016 at 9:32 pm #

    Hello George,

    Thank you for these details. However I do find the order link to be useful, I just wish it pointed to an URL affiliates can actually use. The code for this shortcode is in “class-affiliates-affiliate-stats-renderer-wordpress.php”, right? I’ll take a look and see if I can fix this.

    I am able to see the orders using [affiliates_woocommerce_order] (status=pending doesn’t show any orders as there are no pending orders). However, it seems there’s a clash somewhere in the shortcode as there are a bunch of line that are echoed on all tabs. I tried to see if there was a missing closing tag or something like that (similar to the issue with the link generator) but haven’t found anything so far. It seems to be related to the cart but not our cart plugin (WooCart Pro), the problem persisted even after I deactivated it.

    I’ll let you know if I find anything.

    Regards,
    B

  7. George January 12, 2016 at 6:25 pm #

    Hi Bastien,

    You can hide the order link by using [affiliates_affiliate_stats show_post="false" /].

    The previous shortcode i’ve mentioned you, [affiliates_woocommerce_orders status=”pending” ] works nicely, although it throws a notice when debugging is enabled, it works normally.

    I’ve edited the shortcode on your site as well.

    Cheers

  8. Bastien January 8, 2016 at 5:56 pm #

    Hello George,

    Thanks you for the suggestion. I downloaded and installed the plugin but unfortunately it doesn’t seems to be working. I’ve tried different parameters but it only shows the default message “Showing up to 20 orders”.

    That being said, since it is recommended to use the [affiliates_affiliate_stats /] shortcode in conjunction with this new shortcode, I’d still want to change the link and text displayed in the “Post” column as “Protected: Order – January 7, 2016 @ 02:55 PM” doesn’t carry a lot of useful information to the affiliate and it also links to a 404 page.

    Could we create a custom function using hooks/filters to change this and define a value for the “message” key for different actions? Something along the lines of…

    if (referral_added) {
    $level = affiliate_referral_depth() // Something to calculate the depth of the referral; direct, level 1, lvl2, etc.
    if (wc_order) {
    $action = “Sale”;
    $item = wc_get_order_item;
    $link = wc_get_item_url;
    $post = “<a href=’ ” . $link . ” ‘ rel=”nofollow”> ” . $item . “</a>”;
    }
    if (wc_subscription) {
    $action = “Subscription”;
    $item = wc_get_order_item;
    $link = wc_get_item_url;
    $post = “<a href=” ” . $link . ” ” rel=”nofollow”> ” . $item . “</a>”;
    }
    if (formidable_form) {
    $action = “Submission”;
    $item = wc_get_order_item;
    $link = wc_get_item_url;
    $post = “<a href=” ” . $link . ” ” rel=”nofollow”> ” . $item . “</a>”;
    }

    [… all different scenario]

    $details = $depth . $action;

    }

    return $post, $details;

    Thank you again!

    Kind regards,
    B

  9. George January 8, 2016 at 12:21 pm #

    Hi Bastien,

    You can use affiliates-woocommerce-views a free extension which renders details on the orders being placed.
    After installing it as a normal plugin, you can use it like this for example:
    [affiliates_is_affiliate]

    [affiliates_woocommerce_orders status="pending" ]

    [/affiliates_is_affiliate]

    to render the orders where there is a pending referral.

    The order link surely is not working properly since the order is a protected post.
    The data attribute can accept values like order_id, order_total, order_currency. In general it renders a summary of details involved in the referral.

    Kind regards,
    George

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share