class-wc-email-admin-payment-gateway-enabled.php
2 months ago
class-wc-email-cancelled-order.php
7 months ago
class-wc-email-customer-cancelled-order.php
4 months ago
class-wc-email-customer-completed-order.php
7 months ago
class-wc-email-customer-failed-order.php
7 months ago
class-wc-email-customer-fulfillment-created.php
2 months ago
class-wc-email-customer-fulfillment-deleted.php
2 months ago
class-wc-email-customer-fulfillment-updated.php
1 month ago
class-wc-email-customer-invoice.php
7 months ago
class-wc-email-customer-new-account.php
7 months ago
class-wc-email-customer-note.php
7 months ago
class-wc-email-customer-on-hold-order.php
2 months ago
class-wc-email-customer-partially-refunded-order.php
4 months ago
class-wc-email-customer-pos-completed-order.php
1 month ago
class-wc-email-customer-pos-refunded-order.php
1 month ago
class-wc-email-customer-processing-order.php
7 months ago
class-wc-email-customer-refunded-order.php
7 months ago
class-wc-email-customer-reset-password.php
7 months ago
class-wc-email-customer-review-request.php
1 month ago
class-wc-email-failed-order.php
7 months ago
class-wc-email-new-order.php
7 months ago
class-wc-email.php
4 months ago
class-wc-email-customer-partially-refunded-order.php
112 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class WC_Email_Customer_Partially_Refunded_Order file. |
| 4 | * |
| 5 | * @package WooCommerce\Emails |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | // Include the parent class. |
| 13 | require_once __DIR__ . '/class-wc-email-customer-refunded-order.php'; |
| 14 | |
| 15 | if ( ! class_exists( 'WC_Email_Customer_Partially_Refunded_Order', false ) ) : |
| 16 | |
| 17 | /** |
| 18 | * Customer Partially Refunded Order Email. |
| 19 | * |
| 20 | * Partial refund emails are sent to customers when their order is partially refunded. |
| 21 | * |
| 22 | * This email is a variant of the WC_Email_Customer_Refunded_Order email used only for the block email editor. |
| 23 | * |
| 24 | * The WC_Email_Customer_Refunded_Order email is used for both full and partial refunds. |
| 25 | * |
| 26 | * We created this custom class to maintain backwards compatibility with other integrations that use the WC_Email_Customer_Refunded_Order email. |
| 27 | * |
| 28 | * The next version of WooCommerce will move more of the functionality from the parent class to this custom class. |
| 29 | * |
| 30 | * @class WC_Email_Customer_Partially_Refunded_Order |
| 31 | * @version 10.6.0 |
| 32 | * @package WooCommerce\Classes\Emails |
| 33 | */ |
| 34 | class WC_Email_Customer_Partially_Refunded_Order extends WC_Email_Customer_Refunded_Order { |
| 35 | |
| 36 | /** |
| 37 | * Constructor. |
| 38 | */ |
| 39 | public function __construct() { |
| 40 | parent::__construct(); |
| 41 | |
| 42 | $this->id = 'customer_partially_refunded_order'; |
| 43 | $this->title = __( 'Partially refunded order', 'woocommerce' ); |
| 44 | $this->description = __( 'Notifies customers when their order has been partially refunded.', 'woocommerce' ); |
| 45 | $this->partial_refund = true; |
| 46 | $this->template_block = 'emails/block/customer-partially-refunded-order.php'; |
| 47 | |
| 48 | // Remove triggers for this email because they will be handled by the parent class. |
| 49 | remove_action( 'woocommerce_order_fully_refunded_notification', array( $this, 'trigger_full' ), 10 ); |
| 50 | remove_action( 'woocommerce_order_partially_refunded_notification', array( $this, 'trigger_partial' ), 10 ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Get block editor email template content. |
| 55 | * |
| 56 | * @return string |
| 57 | */ |
| 58 | public function get_block_editor_email_template_content() { |
| 59 | return wc_get_template_html( |
| 60 | $this->template_block_content, |
| 61 | array( |
| 62 | 'order' => $this->object, |
| 63 | 'refund' => $this->refund, |
| 64 | 'partial_refund' => $this->partial_refund, |
| 65 | 'sent_to_admin' => false, |
| 66 | 'plain_text' => false, |
| 67 | 'email' => $this, |
| 68 | ) |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Get email subject. |
| 74 | * |
| 75 | * @return string |
| 76 | */ |
| 77 | public function get_subject() { |
| 78 | $subject = $this->get_option( 'subject_partial', $this->get_default_subject( true ) ); |
| 79 | /** |
| 80 | * Filter the email subject for customer refunded order. |
| 81 | * |
| 82 | * @param string $subject The email subject. |
| 83 | * @param object|bool $order Order object. |
| 84 | * @param WC_Email_Customer_Refunded_Order $email Email object. |
| 85 | * @since 3.7.0 |
| 86 | */ |
| 87 | $subject = apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object, $this ); |
| 88 | if ( $this->block_email_editor_enabled ) { |
| 89 | $subject = $this->personalizer->personalize_transactional_content( $subject, $this ); |
| 90 | } |
| 91 | return $subject; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Return the name of the option in the WP DB. |
| 96 | * |
| 97 | * @since 2.6.0 |
| 98 | * @return string |
| 99 | */ |
| 100 | public function get_option_key() { |
| 101 | $id = 'customer_refunded_order'; |
| 102 | // we need to continue using the parent class's id because we want to maintain backwards compatibility |
| 103 | // and allow the parent class continue managing the settings options for this class. |
| 104 | // We can remove this once we have migrated all the settings options to this class. |
| 105 | return $this->plugin_id . $id . '_settings'; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | endif; |
| 110 | |
| 111 | return new WC_Email_Customer_Partially_Refunded_Order(); |
| 112 |