LLMS_Notification_View_Subscription_Cancelled
Notification View: Purchase Receipt.
Source Source
File: includes/notifications/views/class.llms.notification.view.subscription.cancelled.php
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | class LLMS_Notification_View_Subscription_Cancelled extends LLMS_Abstract_Notification_View { /** * Notification Trigger ID. * * @var string */ public $trigger_id = 'subscription_cancelled' ; /** * Setup body content for output. * * @since 3.17.8 * * @return string */ protected function set_body() { return sprintf( __( '%1$s has cancelled their subscription (#%2$s) to the %3$s %4$s' , 'lifterlms' ), '{{CUSTOMER_NAME}}' , '{{ORDER_ID}}' , '{{PRODUCT_TYPE}}' , '{{PRODUCT_TITLE_LINK}}' ); } /** * Setup footer content for output. * * @since 3.17.8 * * @return string */ protected function set_footer() { return '' ; } /** * Setup notification icon for output. * * @since 3.17.8 * * @return string */ protected function set_icon() { return '' ; } /** * Setup merge codes that can be used with the notification. * * @since 3.17.8 * * @return array */ protected function set_merge_codes() { return array ( '{{CUSTOMER_NAME}}' => __( 'Customer Name' , 'lifterlms' ), '{{ORDER_ID}}' => __( 'Order ID' , 'lifterlms' ), '{{PLAN_TITLE}}' => __( 'Plan Title' , 'lifterlms' ), '{{PRODUCT_TITLE}}' => __( 'Product Title' , 'lifterlms' ), '{{PRODUCT_TYPE}}' => __( 'Product Type' , 'lifterlms' ), '{{PRODUCT_TITLE_LINK}}' => __( 'Product Title (Link)' , 'lifterlms' ), ); } /** * Replace merge codes with actual values. * * @since 3.17.8 * @since 5.4.0 Account for deleted products. * * @param string $code The merge code to ge merged data for. * @return string */ protected function set_merge_data( $code ) { $order = $this ->post; switch ( $code ) { case '{{CUSTOMER_NAME}}' : $code = $order ->get_customer_name(); break ; case '{{ORDER_ID}}' : $code = $order ->get( 'id' ); break ; case '{{PLAN_TITLE}}' : $code = $order ->get( 'plan_title' ); break ; case '{{PRODUCT_TITLE}}' : $code = $order ->get( 'product_title' ); break ; case '{{PRODUCT_TITLE_LINK}}' : $permalink = esc_url( get_permalink( $order ->get( 'product_id' ) ) ); if ( $permalink ) { $title = $this ->set_merge_data( '{{PRODUCT_TITLE}}' ); $code = '<a href="' . $permalink . '">' . $title . '</a>' ; } break ; case '{{PRODUCT_TYPE}}' : $obj = $order ->get_product(); if ( empty ( $obj ) ) { $code = __( '[DELETED ITEM]' , 'lifterlms' ); } elseif ( is_a ( $obj , 'WP_Post' ) ) { $code = _x( 'Item' , 'generic product type description' , 'lifterlms' ); } else { $code = $obj ->get_post_type_label( 'singular_name' ); } break ; } return $code ; } /** * Setup notification subject for output. * * @since 3.17.8 * * @return string */ protected function set_subject() { return esc_html__( 'Subscription Cancellation Notice' , 'lifterlms' ); } /** * Setup notification title for output. * * @since 3.17.8 * * @return string */ protected function set_title() { return sprintf( esc_html__( '%1$s subscription cancellation' , 'lifterlms' ), '{{PRODUCT_TYPE}}' ); } } |
Expand full source code Collapse full source code View on GitHub
Methods Methods
- set_body — Setup body content for output.
- set_footer — Setup footer content for output.
- set_icon — Setup notification icon for output.
- set_merge_codes — Setup merge codes that can be used with the notification.
- set_merge_data — Replace merge codes with actual values.
- set_subject — Setup notification subject for output.
- set_title — Setup notification title for output.
Changelog Changelog
Version | Description |
---|---|
3.17.8 | Introduced. |