domain = 'wc-gateway-bloyal-gift-card'; $this->id = 'bloyal_gift_card'; $this->icon = apply_filters( 'woocommerce_offline_icon', '' ); $this->has_fields = true; $this->method_title = __( 'bLoyal Gift Card', 'wc-gateway-bloyal-gift-card' ); $this->method_description = __( 'Allows payments thorugh bloyal gift card.', 'wc-gateway-bloyal-gift-card' ); $this->init_form_fields(); $this->init_settings(); $this->title = $this->get_option( 'title' ); $this->description = $this->get_option( 'description' ); $this->instructions = $this->get_option( 'instructions', $this->description ); $this->supports = array( 'products', 'refunds', ); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) ); add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); } /** * Initialize Gateway Settings Form Fields */ public function init_form_fields() { $this->form_fields = apply_filters( 'wc_offline_form_fields', array( 'enabled' => array( 'title' => __( 'Enable/Disable', 'wc-gateway-bloyal-gift-card' ), 'type' => 'checkbox', 'label' => __( 'Enable bLoyal Gift Card', 'wc-gateway-bloyal-gift-card' ), 'default' => 'No', ), 'title' => array( 'title' => __( 'Title', 'wc-gateway-bloyal-gift-card' ), 'type' => 'text', 'description' => __( 'This controls the title for the payment method the customer sees during checkout.', 'wc-gateway-bloyal-gift-card' ), 'default' => __( 'Gift Card', 'wc-gateway-bloyal-gift-card' ), 'desc_tip' => true, ), 'description' => array( 'title' => __( 'Description', 'wc-gateway-bloyal-gift-card' ), 'type' => 'textarea', 'description' => __( 'Payment method description that the customer will see on your checkout.', 'wc-gateway-bloyal-gift-card' ), 'default' => __( 'Amount will be deducted from your gift card balance.', 'wc-gateway-bloyal-gift-card' ), 'desc_tip' => true, ), 'validate' => array( 'title' => __( 'Validate', 'wc-gateway-bloyal-gift-card' ), 'type' => 'button', 'description' => __( 'Payment method description that the customer will see on your checkout.', 'wc-gateway-bloyal-gift-card' ), 'default' => __( '', 'wc-gateway-bloyal-gift-card' ), 'desc_tip' => true, ), 'instructions' => array( 'title' => __( 'Instructions', 'wc-gateway-bloyal-gift-card' ), 'type' => 'textarea', 'description' => __( 'Instructions that will be added to the thank you page and emails.', 'wc-gateway-bloyal-gift-card' ), 'default' => __( 'Instructions that will be added to the thank you page and emails.', 'wc-gateway-bloyal-gift-card' ), 'desc_tip' => true, ), ) ); } /** * Output for the order received page. */ public function thankyou_page() { if ( $this->instructions ) { echo wpautop( wptexturize( esc_attr( $this->instructions ) ) ); } } /** * Add content to the WC emails. * * @access public * @param WC_Order $order * @param bool $sent_to_admin * @param bool $plain_text */ public function email_instructions( $order, $sent_to_admin, $plain_text = false ) { try { if ( $this->instructions && ! $sent_to_admin && $this->id === $order->get_payment_method() && $order->has_status( 'on-hold' ) ) { echo wpautop( wptexturize( esc_attr( $this->instructions ) ) ) . PHP_EOL; } } catch ( Exception $e ) { bLoyalLoggerService::write_custom_log( $e->getMessage(), 3 ); } } public function payment_fields() { try { if ( $description = $this->get_description() ) { echo wpautop( wptexturize( esc_attr( $description ) ) ); } } catch ( Exception $e ) { bLoyalLoggerService::write_custom_log( $e->getMessage(), 3 ); } ?>