__( 'Coupon codes', 'webstyle-coupons' ), 'callback' => array( $this, 'export' ), ); return $exporters; } /** * @param array $erasers Registered erasers. */ public function add_eraser( $erasers ) { $erasers['webstyle-coupons'] = array( 'eraser_friendly_name' => __( 'Coupon codes', 'webstyle-coupons' ), 'callback' => array( $this, 'erase' ), ); return $erasers; } /** * @param string $email E-mail address. */ public function export( $email ): array { $found = $this->codes->for_email( (string) $email ); $items = array(); foreach ( $found['codes'] as $code ) { $items[] = array( 'group_id' => 'webstyle-coupons-codes', 'group_label' => __( 'Coupon codes', 'webstyle-coupons' ), 'item_id' => 'webstyle-coupons-code-' . $code->id, 'data' => array( array( 'name' => __( 'Campaign', 'webstyle-coupons' ), 'value' => (string) $code->campaign, ), array( 'name' => __( 'Code', 'webstyle-coupons' ), 'value' => (string) $code->code, ), array( 'name' => __( 'Issued', 'webstyle-coupons' ), 'value' => get_date_from_gmt( (string) $code->created_at ), ), ), ); } foreach ( $found['redemptions'] as $use ) { $items[] = array( 'group_id' => 'webstyle-coupons-uses', 'group_label' => __( 'Coupon code uses', 'webstyle-coupons' ), 'item_id' => 'webstyle-coupons-use-' . $use->id, 'data' => array( array( 'name' => __( 'Campaign', 'webstyle-coupons' ), 'value' => (string) $use->campaign, ), array( 'name' => __( 'Order', 'webstyle-coupons' ), 'value' => (string) $use->order_id, ), array( 'name' => __( 'Discount', 'webstyle-coupons' ), 'value' => (string) $use->discount_amount, ), array( 'name' => __( 'Used', 'webstyle-coupons' ), 'value' => get_date_from_gmt( (string) $use->redeemed_at ), ), ), ); } return array( 'data' => $items, 'done' => true, ); } /** * @param string $email E-mail address. */ public function erase( $email ): array { return array( 'items_removed' => $this->codes->erase_email( (string) $email ) > 0, 'items_retained' => false, 'messages' => array(), 'done' => true, ); } public function policy_text(): void { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } wp_add_privacy_policy_content( __( 'WebStyle Personal Coupons', 'webstyle-coupons' ), wp_kses_post( wpautop( __( 'When we send you a personal discount code, we store your e-mail address with the code so that the code is yours and you receive the same code if it is sent again. When you use a code, we store the order number, your e-mail address and country, the discount and the order total, to count how often a code is used and to see what a campaign brought in. The data stays in this shop and is not shared with others. It is kept until the shop deletes it or you ask for it to be erased.', 'webstyle-coupons' ) ) ) ); } }