addOptionControl( array( 'type' => 'buttons-list', 'name' => __( 'Button Action', 'wpfnl' ), 'slug' => 'offer_action', 'value' => array( 'accept' => __( 'Accept Offer', 'wpfnl' ), 'reject' => __( 'Reject Offer', 'wpfnl' ), ), 'default' => 'accept', ) )->rebuildElementOnChange(); $this->addOptionControl( array( 'type' => 'textfield', 'name' => __( 'Button Text', 'wpfnl' ), 'slug' => 'button_text', 'default' => __( 'Yes, Add to My Order!', 'wpfnl' ), ) )->rebuildElementOnChange(); $this->addOptionControl( array( 'type' => 'buttons-list', 'name' => __( 'Show Product Price', 'wpfnl' ), 'slug' => 'show_product_price', 'value' => array( 'yes' => __( 'Yes', 'wpfnl' ), 'no' => __( 'No', 'wpfnl' ), ), 'default' => 'no', 'condition' => 'offer_action=accept', ) )->rebuildElementOnChange(); $this->addOptionControl( array( 'type' => 'buttons-list', 'name' => __( 'Button Alignment', 'wpfnl' ), 'slug' => 'button_alignment', 'value' => array( 'left' => __( 'Left', 'wpfnl' ), 'center' => __( 'Center', 'wpfnl' ), 'right' => __( 'Right', 'wpfnl' ), ), 'default' => 'left', ) )->rebuildElementOnChange(); } /** * Render element */ function render( $options, $defaults, $content ) { $offer_action = isset( $options['offer_action'] ) ? $options['offer_action'] : 'accept'; $button_text = isset( $options['button_text'] ) ? $options['button_text'] : __( 'Yes, Add to My Order!', 'wpfnl' ); $show_price = isset( $options['show_product_price'] ) ? $options['show_product_price'] : 'no'; $button_align = isset( $options['button_alignment'] ) ? $options['button_alignment'] : 'left'; // Get offer button type from settings or URL $offer_button_type = isset( $options['offer_type'] ) ? $options['offer_type'] : 'upsell'; // Get product data $response = \WPFunnels\Wpfnl_functions::get_product_data_for_widget( get_the_ID() ); $offer_product = isset($response['offer_product']) && $response['offer_product'] ? $response['offer_product'] : ''; $get_product_type = isset($response['get_product_type']) && $response['get_product_type'] ? $response['get_product_type'] : ''; ?>
'; echo '
'; if( 'yes' === $show_price ){ echo ''; } $post_id = get_the_ID(); echo do_shortcode( '[wpf_variable_offer post_id="'.$post_id.'"]' ); echo '
'; } ?>
get_price_html(); } } } } ?>
'; } ?>