PKL\zz#templates/optin-template-simple.phpnuW+Aoptions->get_optin_meta_value( $optin_id, 'wcf-input-fields-skins' ); ?>
' ) { echo esc_html__( 'Your cart is currently empty.', 'cartflows' ); } else { echo $checkout_html; } ?> PKL\p/΄$J$J&classes/class-cartflows-optin-meta.phpnuW+Autils->get_step_post_type(), // Post_type. 'normal', // Context. 'high' // Priority. ); } } /** * Metabox Markup * * @param object $post Post object. * @return void */ public function markup_meta_box( $post ) { wp_nonce_field( 'save-nonce-optin-step-meta', 'nonce-optin-step-meta' ); $stored = get_post_meta( $post->ID ); $optin_meta = self::get_meta_option( $post->ID ); // Set stored and override defaults. foreach ( $stored as $key => $value ) { if ( array_key_exists( $key, $optin_meta ) ) { self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : ''; } else { self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : ''; } } // Get defaults. $meta = self::get_meta_option( $post->ID ); $optin_meta = array(); foreach ( $meta as $key => $value ) { $optin_meta[ $key ] = $meta[ $key ]['default']; } do_action( 'wcf_optin_settings_markup_before' ); $this->tabs_markup( $optin_meta, $post->ID ); do_action( 'wcf_optin_settings_markup_after' ); } /** * Page Header Tabs * * @param array $options options. * @param int $post_id post ID. */ public function tabs_markup( $options, $post_id ) { $active_tab = get_post_meta( $post_id, 'wcf-active-tab', true ); if ( empty( $active_tab ) ) { $active_tab = 'wcf-optin-shortcodes'; } $tab_array = array( array( 'title' => __( 'Shortcodes', 'cartflows' ), 'id' => 'wcf-optin-shortcodes', 'class' => 'wcf-optin-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-editor-code', ), array( 'title' => __( 'Select Product', 'cartflows' ), 'id' => 'wcf-optin-general', 'class' => 'wcf-optin-general' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-info', ), array( 'title' => __( 'Design', 'cartflows' ), 'id' => 'wcf-optin-style', 'class' => 'wcf-optin-style' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-admin-customizer', ), array( 'title' => __( 'Form Fields', 'cartflows' ), 'id' => 'wcf-optin-custom-fields', 'class' => 'wcf-optin-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-welcome-widgets-menus', ), array( 'title' => __( 'Settings', 'cartflows' ), 'id' => 'wcf-optin-custom-settings', 'class' => 'wcf-optin-custom-settings' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-admin-generic', ), array( 'title' => __( 'Custom Script', 'cartflows' ), 'id' => 'wcf-optin-custom-script-header', 'class' => 'wcf-optin-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-format-aside', ), ); $tabs = $tab_array; ?>
$tab ) { ?>
tab_shortcodes( $options, $post_id ); ?> tab_general( $options, $post_id ); ?> tab_style( $options, $post_id ); ?> tab_custom_fields( $options, $post_id ); ?> tab_custom_settings( $options, $post_id ); ?> tab_custom_script( $options, $post_id ); ?> right_column_footer( $options, $post_id ); ?>
meta->get_shortcode_field( array( 'label' => 'Optin Page', 'name' => 'wcf-optin-shortcode', 'content' => '[cartflows_optin]', 'help' => esc_html__( 'Add this shortcode to your optin page', 'cartflows' ), ) ); ?>
meta->get_product_selection_field( array( 'name' => 'wcf-optin-product', 'value' => $options['wcf-optin-product'], 'label' => __( 'Select Free Product', 'cartflows' ), 'help' => __( 'Select Free and Virtual product only.', 'cartflows' ), 'multiple' => false, 'allow_clear' => true, ) ); ?>
meta->get_description_field( array( 'name' => 'wcf-upgrade-to-pro', /* translators: %s: link */ 'content' => '' . sprintf( esc_html__( 'Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature.', 'cartflows' ), '', '' ) . '', ) ); } ?>
meta->get_checkbox_field( array( 'label' => __( 'Pass Fields as URL Parameters', 'cartflows' ), 'name' => 'wcf-optin-pass-fields', 'value' => $options['wcf-optin-pass-fields'], 'after' => __( 'Enable', 'cartflows' ), 'help' => __( 'You can pass specific fields from the form to next step as URL query parameters.', 'cartflows' ), 'toggle' => array( 'fields' => array( 'yes' => array( 'wcf-optin-pass-specific-fields' ), ), ), ) ); echo wcf()->meta->get_text_field( array( 'label' => __( 'Enter form field', 'cartflows' ), 'name' => 'wcf-optin-pass-specific-fields', 'value' => $options['wcf-optin-pass-specific-fields'], 'help' => __( 'Enter comma seprated field name. E.g. first_name, last_name', 'cartflows' ), 'attr' => array( 'placeholder' => __( 'Fields to pass, separated by commas', 'cartflows' ), ), ) ); echo wcf()->meta->get_description_field( array( 'name' => 'wcf-optin-pass-fields-doc', 'content' => __( 'Enter comma seprated field name. E.g. first_name, last_name', 'cartflows' ), /* translators: %s: link */ 'content' => sprintf( esc_html__( 'You can pass field value as a URL parameter to the next step. %1$sClick here%2$s for more information.', 'cartflows' ), '', '' ), ) ); ?>
meta->get_color_picker_field( array( 'label' => __( 'Primary Color', 'cartflows' ), 'name' => 'wcf-primary-color', 'value' => $options['wcf-primary-color'], ) ); echo wcf()->meta->get_font_family_field( array( 'for' => 'wcf-base', 'label' => esc_html__( 'Font Family', 'cartflows' ), 'name' => 'wcf-base-font-family', 'value' => $options['wcf-base-font-family'], ) ); ?>
meta->get_section( array( 'label' => __( 'Input Fields', 'cartflows' ), ) ); $fields_skin_pro_option = array(); if ( ! _is_cartflows_pro() ) { $fields_skin_pro_option = array( 'floating-labels' => __( 'Floating Labels (Available in CartFlows Pro)', 'cartflows' ), ); } echo wcf()->meta->get_select_field( array( 'label' => __( 'Style', 'cartflows' ), 'name' => 'wcf-input-fields-skins', 'value' => $options['wcf-input-fields-skins'], 'options' => array( 'default' => esc_html__( 'Default', 'cartflows' ), 'floating-labels' => esc_html__( 'Floating Labels', 'cartflows' ), ), 'pro-options' => $fields_skin_pro_option, ) ); echo wcf()->meta->get_font_family_field( array( 'for' => 'wcf-input', 'label' => esc_html__( 'Font Family', 'cartflows' ), 'name' => 'wcf-input-font-family', 'value' => $options['wcf-input-font-family'], ) ); echo wcf()->meta->get_font_weight_field( array( 'for' => 'wcf-input', 'label' => esc_html__( 'Font Weight', 'cartflows' ), 'name' => 'wcf-input-font-weight', 'value' => $options['wcf-input-font-weight'], ) ); echo wcf()->meta->get_select_field( array( 'label' => __( 'Size', 'cartflows' ), 'name' => 'wcf-input-field-size', 'value' => $options['wcf-input-field-size'], 'options' => array( '33px' => esc_html__( 'Extra Small', 'cartflows' ), '38px' => esc_html__( 'Small', 'cartflows' ), '44px' => esc_html__( 'Medium', 'cartflows' ), '58px' => esc_html__( 'Large', 'cartflows' ), '68px' => esc_html__( 'Extra Large', 'cartflows' ), 'custom' => esc_html__( 'Custom', 'cartflows' ), ), ) ); echo wcf()->meta->get_number_field( array( 'label' => __( 'Top Bottom Spacing', 'cartflows' ), 'name' => 'wcf-field-tb-padding', 'value' => $options['wcf-field-tb-padding'], ) ); echo wcf()->meta->get_number_field( array( 'label' => __( 'Left Right Spacing', 'cartflows' ), 'name' => 'wcf-field-lr-padding', 'value' => $options['wcf-field-lr-padding'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Label Color', 'cartflows' ), 'name' => 'wcf-field-label-color', 'value' => $options['wcf-field-label-color'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Text / Placeholder Color', 'cartflows' ), 'name' => 'wcf-field-color', 'value' => $options['wcf-field-color'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Background Color', 'cartflows' ), 'name' => 'wcf-field-bg-color', 'value' => $options['wcf-field-bg-color'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Border Color', 'cartflows' ), 'name' => 'wcf-field-border-color', 'value' => $options['wcf-field-border-color'], ) ); ?>
meta->get_section( array( 'label' => __( 'Submit Button', 'cartflows' ), ) ); echo wcf()->meta->get_text_field( array( 'label' => __( 'Button Text', 'cartflows' ), 'name' => 'wcf-submit-button-text', 'value' => $options['wcf-submit-button-text'], 'attr' => array( 'placeholder' => __( 'Submit', 'cartflows' ), ), ) ); echo wcf()->meta->get_number_field( array( 'label' => __( 'Font Size', 'cartflows' ), 'name' => 'wcf-submit-font-size', 'value' => $options['wcf-submit-font-size'], ) ); echo wcf()->meta->get_font_family_field( array( 'for' => 'wcf-button', 'label' => esc_html__( 'Font Family', 'cartflows' ), 'name' => 'wcf-button-font-family', 'value' => $options['wcf-button-font-family'], ) ); echo wcf()->meta->get_font_weight_field( array( 'for' => 'wcf-button', 'label' => esc_html__( 'Font Weight', 'cartflows' ), 'name' => 'wcf-button-font-weight', 'value' => $options['wcf-button-font-weight'], ) ); echo wcf()->meta->get_select_field( array( 'label' => __( 'Size', 'cartflows' ), 'name' => 'wcf-submit-button-size', 'value' => $options['wcf-submit-button-size'], 'options' => array( '33px' => esc_html__( 'Extra Small', 'cartflows' ), '38px' => esc_html__( 'Small', 'cartflows' ), '44px' => esc_html__( 'Medium', 'cartflows' ), '58px' => esc_html__( 'Large', 'cartflows' ), '68px' => esc_html__( 'Extra Large', 'cartflows' ), 'custom' => esc_html__( 'Custom', 'cartflows' ), ), ) ); echo wcf()->meta->get_number_field( array( 'label' => __( 'Top Bottom Spacing', 'cartflows' ), 'name' => 'wcf-submit-tb-padding', 'value' => $options['wcf-submit-tb-padding'], ) ); echo wcf()->meta->get_number_field( array( 'label' => __( 'Left Right Spacing', 'cartflows' ), 'name' => 'wcf-submit-lr-padding', 'value' => $options['wcf-submit-lr-padding'], ) ); echo wcf()->meta->get_select_field( array( 'label' => __( 'Position', 'cartflows' ), 'name' => 'wcf-submit-button-position', 'value' => $options['wcf-submit-button-position'], 'options' => array( 'left' => esc_html__( 'Left', 'cartflows' ), 'center' => esc_html__( 'Center', 'cartflows' ), 'right' => esc_html__( 'Right', 'cartflows' ), ), ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Text Color', 'cartflows' ), 'name' => 'wcf-submit-color', 'value' => $options['wcf-submit-color'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Text Hover Color', 'cartflows' ), 'name' => 'wcf-submit-hover-color', 'value' => $options['wcf-submit-hover-color'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Background Color', 'cartflows' ), 'name' => 'wcf-submit-bg-color', 'value' => $options['wcf-submit-bg-color'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Background Hover Color', 'cartflows' ), 'name' => 'wcf-submit-bg-hover-color', 'value' => $options['wcf-submit-bg-hover-color'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Border Color', 'cartflows' ), 'name' => 'wcf-submit-border-color', 'value' => $options['wcf-submit-border-color'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Border Hover Color', 'cartflows' ), 'name' => 'wcf-submit-border-hover-color', 'value' => $options['wcf-submit-border-hover-color'], ) ); ?>
meta->get_hidden_field( array( 'name' => 'wcf-field-google-font-url', 'value' => $options['wcf-field-google-font-url'], ) ); ?>
options->get_optin_fields( $post_id ); } return self::$meta_option; } /** * Metabox Save * * @param number $post_id Post ID. * @return void */ public function save_meta_box( $post_id ) { // Checks save status. $is_autosave = wp_is_post_autosave( $post_id ); $is_revision = wp_is_post_revision( $post_id ); $is_valid_nonce = ( isset( $_POST['nonce-optin-step-meta'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce-optin-step-meta'] ) ), 'save-nonce-optin-step-meta' ) ) ? true : false; // Exits script depending on save status. if ( $is_autosave || $is_revision || ! $is_valid_nonce ) { return; } wcf()->options->save_optin_fields( $post_id ); } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Optin_Meta::get_instance(); PKL\JJ(classes/class-cartflows-optin-markup.phpnuW+Aelementor_editor_compatibility(); } /** * Elementor editor compatibility. */ public function elementor_editor_compatibility() { if ( ! empty( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] && is_admin() ) { //phpcs:ignore if ( isset( $_GET['post'] ) && ! empty( $_GET['post'] ) ) { //phpcs:ignore if ( _wcf_check_is_optin_by_id( intval( $_GET['post'] ) ) ) { //phpcs:ignore /* Submit Button */ add_filter( 'woocommerce_order_button_text', array( $this, 'place_order_button_text' ), 10, 1 ); } } } } /** * Change order button text . * * @param string $woo_button_text place order. * @return string */ public function place_order_button_text( $woo_button_text ) { $optin_id = get_the_ID(); $wcf_order_button_text = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-button-text' ); if ( ! empty( $wcf_order_button_text ) ) { $woo_button_text = $wcf_order_button_text; } return $woo_button_text; } /** * Display all WooCommerce notices. * * @since 1.1.5 */ public function display_woo_notices() { if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) { woocommerce_output_all_notices(); } } /** * Check for checkout flag * * @param bool $is_checkout is checkout. * * @return bool */ public function woo_checkout_flag( $is_checkout ) { if ( ! is_admin() ) { if ( _is_wcf_optin_type() ) { $is_checkout = true; } } return $is_checkout; } /** * Render checkout shortcode markup. * * @param array $atts attributes. * @return string */ public function optin_shortcode_markup( $atts ) { if ( ! function_exists( 'wc_print_notices' ) ) { $notice_out = '

' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '

'; $notice_out .= ''; return $notice_out; } $atts = shortcode_atts( array( 'id' => 0, ), $atts ); $optin_id = intval( $atts['id'] ); if ( empty( $optin_id ) ) { if ( ! _is_wcf_optin_type() ) { return '

' . __( 'Please place shortcode on Optin step-type only.', 'cartflows' ) . '

'; } global $post; $optin_id = intval( $post->ID ); } $output = ''; ob_start(); do_action( 'cartflows_optin_form_before', $optin_id ); $optin_layout = 'default'; $template_default = CARTFLOWS_OPTIN_DIR . 'templates/optin-template-simple.php'; include $template_default; $output .= ob_get_clean(); return $output; } /** * Configure Cart Data. * * @since 1.0.0 * * @return void */ public function preconfigured_cart_data() { if ( is_admin() ) { return; } global $post; if ( _is_wcf_optin_type() ) { if ( wp_doing_ajax() ) { return; } else { $optin_id = $post->ID; do_action( 'cartflows_optin_before_configure_cart', $optin_id ); $products = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-optin-product' ); if ( ! is_array( $products ) ) { return; } /* Empty the current cart */ WC()->cart->empty_cart(); if ( is_array( $products ) && count( $products ) < 1 ) { wc_add_notice( __( 'No product is selected. Please select a Simple, Virtual and Free product from the meta settings.', 'cartflows' ), 'error' ); return; } /* Set customer session if not set */ if ( ! is_user_logged_in() && WC()->cart->is_empty() ) { WC()->session->set_customer_session_cookie( true ); } $product_id = reset( $products ); $_product = wc_get_product( $product_id ); if ( ! empty( $_product ) ) { if ( $_product->is_type( 'simple' ) && $_product->is_virtual() ) { if ( $_product->get_price() > 0 ) { wc_add_notice( __( 'Please update the selected product\'s price to zero (0).', 'cartflows' ), 'error' ); } else { $quantity = 1; WC()->cart->add_to_cart( $product_id, $quantity ); } } else { wc_add_notice( __( 'Please select a Simple, Virtual and Free product.', 'cartflows' ), 'error' ); } } else { wc_add_notice( __( 'Please select a Simple, Virtual and Free product.', 'cartflows' ), 'error' ); } do_action( 'cartflows_optin_after_configure_cart', $optin_id ); } } } /** * Load shortcode data. * * @return void */ public function shortcode_load_data() { if ( _is_wcf_optin_type() ) { add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 ); add_action( 'wp_enqueue_scripts', array( $this, 'compatibility_scripts' ), 101 ); /* Show notices if cart has errors */ add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' ); // Outputting the hidden field in checkout page. add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 ); add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 ); /* Remove unnecessary option */ add_filter( 'woocommerce_enable_order_notes_field', '__return_false' ); add_filter( 'woocommerce_cart_needs_shipping_address', '__return_false' ); remove_all_actions( 'woocommerce_before_checkout_form' ); remove_all_actions( 'woocommerce_checkout_billing' ); remove_all_actions( 'woocommerce_checkout_shipping' ); remove_all_actions( 'woocommerce_checkout_before_order_review' ); remove_all_actions( 'woocommerce_checkout_order_review' ); remove_all_actions( 'woocommerce_checkout_after_order_review' ); add_filter( 'woocommerce_cart_needs_payment', '__return_false' ); add_filter( 'woocommerce_available_payment_gateways', array( $this, 'disable_payment_gateways' ) ); /* Paypal Expresss remove */ if ( function_exists( 'wc_gateway_ppec' ) ) { remove_action( 'wp_enqueue_scripts', array( wc_gateway_ppec()->cart, 'enqueue_scripts' ) ); } // Hook in actions once. add_action( 'woocommerce_before_checkout_form', 'woocommerce_output_all_notices', 10 ); add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) ); add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) ); add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); /* Submit Button */ add_filter( 'woocommerce_order_button_text', array( $this, 'place_order_button_text' ), 10, 1 ); add_filter( 'woocommerce_get_terms_and_conditions_checkbox_text', '__return_false' ); global $post; $optin_id = $post->ID; do_action( 'cartflows_optin_before_shortcode', $optin_id ); } } /** * Disable payment gateways. * * @param array $available_gateways gateways. * @return array */ public function disable_payment_gateways( $available_gateways ) { if ( ! is_admin() ) { $available_gateways = array(); } return $available_gateways; } /** * Render checkout ID hidden field. * * @param array $checkout checkout session data. * @return void */ public function checkout_shortcode_post_id( $checkout ) { if ( ! _is_wcf_optin_type() ) { return; } global $post; $optin_id = $post->ID; $flow_id = get_post_meta( $optin_id, 'wcf-flow-id', true ); echo ''; echo ''; } /** * Load shortcode scripts. * * @return void */ public function shortcode_scripts() { wp_enqueue_style( 'wcf-optin-template', wcf()->utils->get_css_url( 'optin-template' ), '', CARTFLOWS_VER ); wp_enqueue_script( 'wcf-optin-template', wcf()->utils->get_js_url( 'optin-template' ), array( 'jquery' ), CARTFLOWS_VER, true ); do_action( 'cartflows_optin_scripts' ); $style = $this->generate_style(); wp_add_inline_style( 'wcf-optin-template', $style ); } /** * Load compatibility scripts. * * @return void */ public function compatibility_scripts() { global $post; $optin_id = $post->ID; // Add DIVI Compatibility css if DIVI theme is enabled. if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() || Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $optin_id ) ) { wp_enqueue_style( 'wcf-optin-template-divi', wcf()->utils->get_css_url( 'optin-template-divi' ), '', CARTFLOWS_VER ); } } /** * Generate styles. * * @return string */ public function generate_style() { global $post; $optin_id = $post->ID; /* Load all fonts */ CartFlows_Font_Families::render_fonts( $optin_id ); $r = ''; $g = ''; $b = ''; $output = ''; /* Global */ $primary_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-primary-color' ); $base_font_family = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-base-font-family' ); /* Input Fields */ $input_font_family = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-input-font-family' ); $input_font_weight = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-input-font-weight' ); $field_input_size = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-input-field-size' ); $field_tb_padding = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-field-tb-padding' ); $field_lr_padding = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-field-lr-padding' ); $field_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-field-color' ); $field_bg_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-field-bg-color' ); $field_border_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-field-border-color' ); $field_label_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-field-label-color' ); if ( 'custom' == $field_input_size ) { $field_input_size = '38px'; } /* Submit Button */ $submit_button_width = '100%'; $optin_button_position = ''; $button_font_size = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-font-size' ); $button_font_family = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-button-font-family' ); $button_font_weight = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-button-font-weight' ); $submit_button_height = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-button-size' ); $submit_tb_padding = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-tb-padding' ); $submit_lr_padding = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-lr-padding' ); $submit_button_position = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-button-position' ); $submit_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-color' ); $submit_hover_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-hover-color' ); $submit_bg_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-bg-color', $primary_color ); $submit_bg_hover_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-bg-hover-color', $primary_color ); $submit_border_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-border-color', $primary_color ); $submit_border_hover_color = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-border-hover-color', $primary_color ); if ( 'custom' == $submit_button_height ) { $submit_button_height = '38px'; $submit_button_width = 'auto'; switch ( $submit_button_position ) { case 'left': $optin_button_position = '0 auto 0 0'; break; case 'center': $optin_button_position = '0 auto'; break; case 'right': $optin_button_position = '0 0 0 auto'; break; default: $optin_button_position = '0 auto'; break; } } if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() || Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $optin_id ) ) { include CARTFLOWS_OPTIN_DIR . 'includes/optin-dynamic-divi-css.php'; } else { include CARTFLOWS_OPTIN_DIR . 'includes/optin-dynamic-css.php'; } return $output; } /** * Get ajax end points. * * @param string $endpoint_url end point URL. * @param string $request end point request. * @return string */ public function get_ajax_endpoint( $endpoint_url, $request ) { global $post; if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) { if ( _is_wcf_optin_type() ) { if ( mb_strpos( $endpoint_url, 'checkout', 0, 'utf-8' ) === false ) { if ( '' === $request ) { $query_args = array( 'wc-ajax' => '%%endpoint%%', ); } else { $query_args = array( 'wc-ajax' => $request, ); } $uri = explode( '?', $_SERVER['REQUEST_URI'], 2 ); //phpcs:ignore $uri = $uri[0]; $endpoint_url = esc_url( add_query_arg( $query_args, $uri ) ); } } } return $endpoint_url; } /** * Save checkout fields. * * @param int $order_id order id. * @param array $posted posted data. * @return void */ public function save_optin_fields( $order_id, $posted ) { if ( isset( $_POST['_wcf_optin_id'] ) ) { //phpcs:ignore $optin_id = wc_clean( wp_unslash( $_POST['_wcf_optin_id'] ) ); //phpcs:ignore update_post_meta( $order_id, '_wcf_optin_id', $optin_id ); if ( isset( $_POST['_wcf_flow_id'] ) ) { //phpcs:ignore $flow_id = wc_clean( wp_unslash( $_POST['_wcf_flow_id'] ) ); //phpcs:ignore update_post_meta( $order_id, '_wcf_flow_id', $flow_id ); } } } /** * Redirect users to our checkout if hidden param * * @param string $redirect redirect url. * @param object $user user. * @return string */ public function after_login_redirect( $redirect, $user ) { if ( isset( $_POST['_wcf_optin_id'] ) ) { //phpcs:ignore $optin_id = intval( $_POST['_wcf_optin_id'] ); //phpcs:ignore $redirect = get_permalink( $optin_id ); } return $redirect; } /** * Add custom class to the fields to change the UI to three column. * * @param array $fields fields. */ public function set_optin_default_fields( $fields ) { if ( _is_wcf_optin_type() ) { global $post; $optin_id = $post->ID; } else { if ( _is_wcf_doing_optin_ajax() && wcf()->utils->get_optin_id_from_post_data() ) { $optin_id = wcf()->utils->get_optin_id_from_post_data(); } else { return $fields; } } $first_name = $fields['first_name']; $last_name = $fields['last_name']; /* Make fields required */ $first_name['required'] = true; $last_name['required'] = true; $fields = array( 'first_name' => $first_name, 'last_name' => $last_name, ); return apply_filters( 'cartflows_optin_default_fields', $fields, $optin_id ); } /** * Add custom class to the fields to change the UI to three column. * * @param array $fields fields. */ public function set_optin_fields( $fields ) { if ( _is_wcf_optin_type() ) { global $post; $optin_id = $post->ID; } else { if ( _is_wcf_doing_optin_ajax() && wcf()->utils->get_optin_id_from_post_data() ) { $optin_id = wcf()->utils->get_optin_id_from_post_data(); } else { return $fields; } } $billing_first_name = $fields['billing']['billing_first_name']; $billing_last_name = $fields['billing']['billing_last_name']; $billing_email = $fields['billing']['billing_email']; $fields['billing'] = array( 'billing_first_name' => $billing_first_name, 'billing_last_name' => $billing_last_name, 'billing_email' => $billing_email, ); return apply_filters( 'cartflows_optin_fields', $fields, $optin_id ); } /** * Billing field customization. * * @param array $fields fields data. * @param string $country country name. * @return array */ public function billing_optin_fields( $fields, $country ) { if ( _is_wcf_optin_type() ) { global $post; $optin_id = $post->ID; } else { if ( _is_wcf_doing_optin_ajax() && wcf()->utils->get_optin_id_from_post_data() ) { $optin_id = wcf()->utils->get_optin_id_from_post_data(); } else { return $fields; } } if ( is_wc_endpoint_url( 'edit-address' ) ) { return $fields; } $billing_first_name = $fields['billing_first_name']; $billing_last_name = $fields['billing_last_name']; $billing_email = $fields['billing_email']; /* Make fields required */ $billing_first_name['required'] = true; $billing_last_name['required'] = true; $fields = array( 'billing_first_name' => $billing_first_name, 'billing_last_name' => $billing_last_name, 'billing_email' => $billing_email, ); return apply_filters( 'cartflows_billing_optin_fields', $fields, $country, $optin_id ); } /** * Replace billing label. * * @param string $notice Notice. * @param string $field_label Field name. * @return string */ public function change_field_label_in_required_notice( $notice, $field_label ) { if ( _is_wcf_doing_optin_ajax() ) { $notice = str_replace( 'Billing ', '', $notice ); } return $notice; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Optin_Markup::get_instance(); PKL\<class-cartflows-optin.phpnuW+A