File manager - Edit - /home/theblueo/tv/fb4e3b/checkout.tar
Back
class-cartflows-checkout.php 0000666 00000001635 15214214053 0012175 0 ustar 00 <?php /** * Checkout * * @package Woo Funnel Cart */ define( 'CARTFLOWS_CHECKOUT_DIR', CARTFLOWS_DIR . 'modules/checkout/' ); define( 'CARTFLOWS_CHECKOUT_URL', CARTFLOWS_URL . 'modules/checkout/' ); /** * Initial Setup * * @since 1.0.0 */ class Cartflows_Checkout { /** * Member Variable * * @var object instance */ private static $instance; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor function that initializes required actions and hooks */ public function __construct() { require_once CARTFLOWS_CHECKOUT_DIR . 'classes/class-cartflows-checkout-markup.php'; require_once CARTFLOWS_CHECKOUT_DIR . 'classes/class-cartflows-checkout-meta.php'; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Checkout::get_instance(); includes/checkout-dynamic-divi-css.php 0000666 00000017066 15214214053 0014044 0 ustar 00 <?php /** * Dynamic checkout divi css * * @package CartFlows */ $output = " .et_pb_module #wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove:hover{ color:$primary_color !important; border:1px solid $primary_color !important; } .et_pb_module #wcf-embed-checkout-form .wcf-checkout-header-image img{ width: {$header_logo_width}px; } .et_pb_module #wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before, .et_pb_module #wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{ color: {$primary_color} !important; } .et_pb_module #wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{ background-color: {$primary_color}; } .et_pb_module #wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus, .et_pb_module #wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus, .et_pb_module #wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus, .et_pb_module #wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{ border-color: {$primary_color} !important; box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8) !important; } .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout label{ color: {$field_label_color}; } .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{ background-color: {$hl_bg_color}; font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .et_pb_module #wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before, .et_pb_module #wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before, .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before { border-bottom-color: {$hl_bg_color}; border-right-color: transparent; border-left-color: transparent; border-top-color: transparent; position: absolute; } .et_pb_module #wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label, .et_pb_module #wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{ font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .et_pb_module #wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'], .et_pb_module #wcf-embed-checkout-form .woocommerce form .form-row input.input-text, .et_pb_module #wcf-embed-checkout-form .woocommerce form .form-row textarea, .et_pb_module #wcf-embed-checkout-form .select2-container--default .select2-selection--single { color: {$field_color} !important; background-color: {$field_bg_color} !important; border-color: {$field_border_color} !important; padding-top: {$field_tb_padding}px; padding-bottom: {$field_tb_padding}px; padding-left: {$field_lr_padding}px; padding-right: {$field_lr_padding}px; min-height: {$field_input_size} !important; font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .et_pb_module #wcf-embed-checkout-form.wcf-field-style-one .woocommerce .form-row input[type='text'], .et_pb_module #wcf-embed-checkout-form.wcf-field-style-one .woocommerce .form-row input[type='email'], .et_pb_module #wcf-embed-checkout-form.wcf-field-style-one .woocommerce .form-row input[type='password'], .et_pb_module #wcf-embed-checkout-form.wcf-field-style-one .woocommerce .form-row input[type='tel'], .et_pb_module #wcf-embed-checkout-form.wcf-field-style-one .select2-container--default .select2-selection--single{ padding:{$field_tb_padding}px {$field_lr_padding}px !important; } .et_pb_module #wcf-embed-checkout-form .woocommerce .col2-set .col-1, .et_pb_module #wcf-embed-checkout-form .woocommerce .col2-set .col-2, .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout .shop_table, .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout #order_review_heading, .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout #payment, .et_pb_module #wcf-embed-checkout-form .woocommerce form.checkout_coupon { background-color: {$section_bg_color}; border-color: {$box_border_color}; font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .et_pb_module #wcf-embed-checkout-form .woocommerce table.shop_table th{ color: {$field_label_color}; } /*.et_pb_module #wcf-embed-checkout-form .woocommerce .woocommerce-info, .et_pb_module #wcf-embed-checkout-form .woocommerce-message{ border-top-color: {$primary_color}; background-color: {$hl_bg_color}; }*/ .et_pb_module #wcf-embed-checkout-form .woocommerce a:not(.wcf-next-button){ color: {$primary_color} !important; } .et_pb_module #wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered { color: {$field_color}; } .et_pb_module #wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */ color: {$field_color}; } .et_pb_module #wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */ color: {$field_color}; } .et_pb_module #wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */ color: {$field_color}; } .et_pb_module #wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */ color: {$field_color}; } .et_pb_module #wcf-embed-checkout-form .woocommerce form p.form-row label { color: {$field_label_color}; font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .et_pb_module #wcf-embed-checkout-form .woocommerce #order_review button, .et_pb_module #wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button, .et_pb_module #wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small { color: {$submit_color}; background: {$submit_bg_color}; padding-top: {$submit_tb_padding}px; padding-bottom: {$submit_tb_padding}px; padding-left: {$submit_lr_padding}px; padding-right: {$submit_lr_padding}px; border-color: {$submit_border_color}; min-height: {$submit_button_height}; font-family: {$button_font_family}; font-weight: {$button_font_weight}; } .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button, .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{ background: {$submit_bg_color}; border: 1px {$submit_border_color} solid; color: {$submit_color}; min-height: {$submit_button_height}; font-family: {$button_font_family}; font-weight: {$button_font_weight}; } .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover, .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover, .et_pb_module #wcf-embed-checkout-form .woocommerce #payment #place_order:hover, .et_pb_module #wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{ color: {$submit_hover_color}; background-color: {$submit_bg_hover_color}; border-color: {$submit_border_hover_color}; } .et_pb_module #wcf-embed-checkout-form .woocommerce h3, .et_pb_module #wcf-embed-checkout-form .woocommerce h3 span, .et_pb_module #wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{ color: {$section_heading_color}; font-family: {$heading_font_family}; font-weight: {$heading_font_weight}; } .et_pb_module #wcf-embed-checkout-form .woocommerce-info::before, .et_pb_module #wcf-embed-checkout-form .woocommerce-message::before{ color: {$primary_color}; } .et_pb_module #wcf-embed-checkout-form { font-family: {$base_font_family}; } img.emoji, img.wp-smiley {}"; includes/checkout-dynamic-css.php 0000666 00000014275 15214214053 0013112 0 ustar 00 <?php /** * Dynamic checkout css * * @package CartFlows */ $output = " .wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove:hover{ color:$primary_color !important; border:1px solid $primary_color !important; } .wcf-embed-checkout-form .wcf-checkout-header-image img{ width: {$header_logo_width}px; } .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before, .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{ color: {$primary_color}; } .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{ background-color: {$primary_color}; } .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus, .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus, .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus, .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{ border-color: {$primary_color}; box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8); } .wcf-embed-checkout-form .woocommerce-checkout label{ color: {$field_label_color}; } .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{ background-color: {$hl_bg_color}; font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before, .wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before, .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before { border-bottom-color: {$hl_bg_color}; border-right-color: transparent; border-left-color: transparent; border-top-color: transparent; position: absolute; } .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label, .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{ font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'], .wcf-embed-checkout-form .woocommerce form .form-row input.input-text, .wcf-embed-checkout-form .woocommerce form .form-row textarea, .wcf-embed-checkout-form .select2-container--default .select2-selection--single, .wcf-embed-checkout-form .woocommerce form .form-row select.select { color: {$field_color}; background: {$field_bg_color}; border-color: {$field_border_color}; padding-top: {$field_tb_padding}px; padding-bottom: {$field_tb_padding}px; padding-left: {$field_lr_padding}px; padding-right: {$field_lr_padding}px; min-height: {$field_input_size}; font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .wcf-embed-checkout-form .woocommerce .col2-set .col-1, .wcf-embed-checkout-form .woocommerce .col2-set .col-2, .wcf-embed-checkout-form .woocommerce-checkout .shop_table, .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading, .wcf-embed-checkout-form .woocommerce-checkout #payment, .wcf-embed-checkout-form .woocommerce form.checkout_coupon { background-color: {$section_bg_color}; border-color: {$box_border_color}; font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .woocommerce table.shop_table th{ color: {$field_label_color}; } /*.wcf-embed-checkout-form .woocommerce .woocommerce-info, .wcf-embed-checkout-form .woocommerce-message{ border-top-color: {$primary_color}; background-color: {$hl_bg_color}; }*/ .wcf-embed-checkout-form .woocommerce a{ color: {$primary_color}; } .wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered { color: {$field_color}; } .wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */ color: {$field_color}; } .wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */ color: {$field_color}; } .wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */ color: {$field_color}; } .wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */ color: {$field_color}; } .wcf-embed-checkout-form .woocommerce form p.form-row label { color: {$field_label_color}; font-family: {$input_font_family}; font-weight: {$input_font_weight}; } .wcf-embed-checkout-form .woocommerce #order_review button, .wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button, .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small { color: {$submit_color}; background: {$submit_bg_color}; padding-top: {$submit_tb_padding}px; padding-bottom: {$submit_tb_padding}px; padding-left: {$submit_lr_padding}px; padding-right: {$submit_lr_padding}px; border-color: {$submit_border_color}; min-height: {$submit_button_height}; font-family: {$button_font_family}; font-weight: {$button_font_weight}; } .wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button, .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{ background: {$submit_bg_color}; border: 1px {$submit_border_color} solid; color: {$submit_color}; min-height: {$submit_button_height}; font-family: {$button_font_family}; font-weight: {$button_font_weight}; } .wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover, .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover, .wcf-embed-checkout-form .woocommerce #payment #place_order:hover, .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{ color: {$submit_hover_color}; background-color: {$submit_bg_hover_color}; border-color: {$submit_border_hover_color}; } .wcf-embed-checkout-form .woocommerce h3, .wcf-embed-checkout-form .woocommerce h3 span, .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{ color: {$section_heading_color}; font-family: {$heading_font_family}; font-weight: {$heading_font_weight}; } .wcf-embed-checkout-form .woocommerce-info::before, .wcf-embed-checkout-form .woocommerce-message::before{ color: {$primary_color}; } .wcf-embed-checkout-form{ font-family: {$base_font_family}; } img.emoji, img.wp-smiley {}"; classes/class-cartflows-checkout-markup.php 0000666 00000102541 15214214053 0015125 0 ustar 00 <?php /** * Checkout markup. * * @package CartFlows */ /** * Checkout Markup * * @since 1.0.0 */ class Cartflows_Checkout_Markup { /** * Member Variable * * @var object instance */ private static $instance; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor */ public function __construct() { /* Set is checkout flag */ add_filter( 'woocommerce_is_checkout', array( $this, 'woo_checkout_flag' ), 9999 ); add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'save_checkout_fields' ), 10, 2 ); /* Show notice if cart is empty */ add_action( 'cartflows_checkout_cart_empty', array( $this, 'display_woo_notices' ) ); /* Checkout Shortcode */ add_shortcode( 'cartflows_checkout', array( $this, 'checkout_shortcode_markup' ) ); /* Preconfigured cart data */ add_action( 'wp', array( $this, 'preconfigured_cart_data' ), 1 ); /* Embed Checkout */ add_action( 'wp', array( $this, 'shortcode_load_data' ), 999 ); /* Ajax Endpoint */ add_filter( 'woocommerce_ajax_get_endpoint', array( $this, 'get_ajax_endpoint' ), 10, 2 ); add_filter( 'cartflows_add_before_main_section', array( $this, 'enable_logo_in_header' ) ); add_filter( 'cartflows_primary_container_bottom', array( $this, 'show_cartflows_copyright_message' ) ); add_filter( 'woocommerce_login_redirect', array( $this, 'after_login_redirect' ), 10, 2 ); add_action( 'wp_ajax_wcf_woo_apply_coupon', array( $this, 'apply_coupon' ) ); add_action( 'wp_ajax_nopriv_wcf_woo_apply_coupon', array( $this, 'apply_coupon' ) ); add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) ); /* Global Checkout */ add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 ); add_action( 'wp_ajax_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) ); add_action( 'wp_ajax_nopriv_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) ); add_action( 'wp_ajax_wcf_woo_remove_cart_product', array( $this, 'wcf_woo_remove_cart_product' ) ); add_action( 'wp_ajax_nopriv_wcf_woo_remove_cart_product', array( $this, 'wcf_woo_remove_cart_product' ) ); add_filter( 'woocommerce_paypal_args', array( $this, 'modify_paypal_args' ), 10, 2 ); add_filter( 'woocommerce_cart_item_name', array( $this, 'wcf_add_remove_label' ), 10, 3 ); } /** * Modify WooCommerce paypal arguments. * * @param array $args argumenets for payment. * @param WC_Order $order order data. * @return array */ public function modify_paypal_args( $args, $order ) { $checkout_id = wcf()->utils->get_checkout_id_from_post_data(); if ( ! $checkout_id ) { return $args; } // Set cancel return URL. $args['cancel_return'] = esc_url_raw( $order->get_cancel_order_url_raw( get_permalink( $checkout_id ) ) ); return $args; } /** * Modify WooCommerce paypal arguments. * * @param string $product_name product name. * @param object $cart_item cart item. * @param string $cart_item_key cart item key. * @return string */ public function wcf_add_remove_label( $product_name, $cart_item, $cart_item_key ) { $checkout_id = get_the_ID(); if ( ! $checkout_id ) { $checkout_id = ( isset( $_POST['option']['checkout_id'] ) ) ? wp_unslash( $_POST['option']['checkout_id'] ) : '';//phpcs:ignore } if ( ! empty( $checkout_id ) ) { $is_remove_product_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-remove-product-field' ); if ( 'checkout' === get_post_meta( $checkout_id, 'wcf-step-type', true ) && ( 'yes' === $is_remove_product_option ) ) { $remove_label = apply_filters( 'woocommerce_cart_item_remove_link', sprintf( '<a href="#" rel="nofollow" class="remove cartflows-icon-close" data-id="%s" data-item-key="%s" ></a>', esc_attr( $cart_item['product_id'] ), $cart_item_key ), $cart_item_key ); $product_name = $remove_label . $product_name; } } return $product_name; } /** * Change order button text . * * @param string $woo_button_text place order. * @return string */ public function place_order_button_text( $woo_button_text ) { $checkout_id = get_the_ID(); if ( ! $checkout_id ) { $checkout_id = ( isset( $_POST['option']['checkout_id'] ) ) ? intval( $_POST['option']['checkout_id'] ) : 0; //phpcs:ignore } $wcf_order_button_text = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-place-order-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(); } } /** * Redirect from default to the global checkout page * * @since 1.0.0 */ public function global_checkout_template_redirect() { if ( ! is_checkout() ) { return; } if ( wcf()->utils->is_step_post_type() ) { return; } // Return if the key OR Order paramater is found in the URL for certain Payment gateways. if ( isset( $_GET['key'] ) || isset( $_GET['order'] ) ) { //phpcs:ignore return; } // redirect only for cartflows checkout pages. $order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' ); $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' ); $common = Cartflows_Helper::get_common_settings(); $global_checkout = $common['global_checkout']; if ( isset( $_SERVER['REQUEST_URI'] ) && // ignore on order-pay. false === wcf_mb_strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/' . $order_pay_endpoint . '/' ) && // ignore on TY page. false === wcf_mb_strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/' . $order_received_endpoint . '/' ) && // ignore if order-pay in query param. false === wcf_mb_strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), $order_pay_endpoint . '=' ) ) { if ( '' !== $global_checkout ) { $link = apply_filters( 'cartflows_global_checkout_url', get_permalink( $global_checkout ) ); if ( ! empty( $link ) ) { wp_safe_redirect( $link ); die(); } } } } /** * 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_checkout_type() || _is_wcf_checkout_shortcode() ) { $is_checkout = true; } } return $is_checkout; } /** * Render checkout shortcode markup. * * @param array $atts attributes. * @return string */ public function checkout_shortcode_markup( $atts ) { if ( ! function_exists( 'wc_print_notices' ) ) { $notice_out = '<p class="woocommerce-notice">' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '</p>'; $notice_out .= '<button onClick="location.reload()">' . __( 'Click Here to Reload', 'cartflows' ) . '</button>'; return $notice_out; } $atts = shortcode_atts( array( 'id' => 0, ), $atts ); $checkout_id = intval( $atts['id'] ); if ( empty( $checkout_id ) ) { if ( ! _is_wcf_checkout_type() ) { return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>'; } global $post; $checkout_id = intval( $post->ID ); } $output = ''; ob_start(); do_action( 'cartflows_checkout_form_before', $checkout_id ); $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' ); $template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php'; $template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout ); if ( file_exists( $template_layout ) ) { include $template_layout; } else { 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_checkout_type() || _is_wcf_checkout_shortcode() ) { if ( wp_doing_ajax() ) { return; } else { if ( _is_wcf_checkout_type() ) { $checkout_id = $post->ID; } else { $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content ); } $global_checkout = intval( Cartflows_Helper::get_common_setting( 'global_checkout' ) ); if ( ! empty( $global_checkout ) && $checkout_id === $global_checkout ) { if ( WC()->cart->is_empty() ) { wc_add_notice( __( 'Your cart is currently empty.', 'cartflows' ), 'error' ); } return; } if ( apply_filters( 'cartflows_skip_configure_cart', false, $checkout_id ) ) { return; } do_action( 'cartflows_checkout_before_configure_cart', $checkout_id ); $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id ); if ( wcf()->flow->is_flow_testmode( $flow_id ) ) { $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' ); } else { $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' ); } if ( ! is_array( $products ) ) { if ( 'dummy' === $products ) { $args = array( 'posts_per_page' => 1, 'orderby' => 'rand', 'post_type' => 'product', 'meta_query' => array( //phpcs:ignore // Exclude out of stock products. array( 'key' => '_stock_status', 'value' => 'outofstock', 'compare' => 'NOT IN', ), ), 'tax_query' => array( //phpcs:ignore array( 'taxonomy' => 'product_type', 'field' => 'slug', 'terms' => 'simple', ), ), ); $random_product = get_posts( $args ); if ( isset( $random_product[0]->ID ) ) { $products = array( array( 'product' => $random_product[0]->ID, ), ); } else { return; } } else { 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 products from the checkout meta settings to continue.', '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 ); } $cart_product_count = 0; foreach ( $products as $index => $data ) { if ( ! isset( $data['product'] ) ) { return; } if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) { break; } $product_id = $data['product']; $_product = wc_get_product( $product_id ); if ( ! empty( $_product ) ) { $quantity = 1; if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) { if ( $_product->is_type( 'variable' ) ) { $default_attributes = $_product->get_default_attributes(); if ( ! empty( $default_attributes ) ) { foreach ( $_product->get_children() as $variation_id ) { $single_variation = new WC_Product_Variation( $variation_id ); if ( $default_attributes == $single_variation->get_attributes() ) { WC()->cart->add_to_cart( $variation_id, $quantity ); $cart_product_count++; } } } else { $product_childrens = $_product->get_children(); if ( isset( $product_childrens[0] ) ) { WC()->cart->add_to_cart( $product_childrens[0], $quantity ); $cart_product_count++; } else { echo '<p>' . esc_html__( 'Variations Not set', 'cartflows' ) . '</p>'; } } } else { WC()->cart->add_to_cart( $product_id, $quantity ); $cart_product_count++; } } else { $wrong_product_notice = __( 'This product can\'t be purchased', 'cartflows' ); wc_add_notice( $wrong_product_notice ); /** WC()->cart->add_to_cart( $product_id, $quantity );. */ } } } /* Since 1.2.2 */ wcf_do_action_deprecated( 'cartflows_checkout_aftet_configure_cart', array( $checkout_id ), '1.2.2', 'cartflows_checkout_after_configure_cart' ); do_action( 'cartflows_checkout_after_configure_cart', $checkout_id ); } } } /** * Load shortcode data. * * @return void */ public function shortcode_load_data() { if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) { 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' ); add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 ); add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 ); // 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_all_actions( 'woocommerce_checkout_billing' ); remove_all_actions( 'woocommerce_checkout_shipping' ); // Hook in actions once. add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) ); add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) ); remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' ); add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) ); add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) ); add_filter( 'woocommerce_cart_totals_coupon_html', array( $this, 'remove_coupon_text' ) ); add_filter( 'woocommerce_order_button_text', array( $this, 'place_order_button_text' ), 10, 1 ); global $post; if ( _is_wcf_checkout_type() ) { $checkout_id = $post->ID; } else { $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content ); } do_action( 'cartflows_checkout_before_shortcode', $checkout_id ); } } /** * Render checkout ID hidden field. * * @param array $checkout checkout session data. * @return void */ public function checkout_shortcode_post_id( $checkout ) { global $post; if ( _is_wcf_checkout_type() ) { $checkout_id = $post->ID; } else { $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content ); } $flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true ); echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">'; echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">'; } /** * Load shortcode scripts. * * @return void */ public function shortcode_scripts() { wp_enqueue_style( 'wcf-checkout-template', wcf()->utils->get_css_url( 'checkout-template' ), '', CARTFLOWS_VER ); wp_enqueue_script( 'wcf-checkout-template', wcf()->utils->get_js_url( 'checkout-template' ), array( 'jquery' ), CARTFLOWS_VER, true ); do_action( 'cartflows_checkout_scripts' ); $style = $this->generate_style(); wp_add_inline_style( 'wcf-checkout-template', $style ); } /** * Load compatibility scripts. * * @return void */ public function compatibility_scripts() { global $post; if ( _is_wcf_checkout_type() ) { $checkout_id = $post->ID; } else { $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content ); } // 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( $checkout_id ) ) { wp_enqueue_style( 'wcf-checkout-template-divi', wcf()->utils->get_css_url( 'checkout-template-divi' ), '', CARTFLOWS_VER ); } // Add Flatsome Compatibility css if Flatsome theme is enabled. if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) { wp_enqueue_style( 'wcf-checkout-template-flatsome', wcf()->utils->get_css_url( 'checkout-template-flatsome' ), '', CARTFLOWS_VER ); } // Add The7 Compatibility css if The7 theme is enabled. if ( Cartflows_Compatibility::get_instance()->is_the_seven_enabled() ) { wp_enqueue_style( 'wcf-checkout-template-the-seven', wcf()->utils->get_css_url( 'checkout-template-the-seven' ), '', CARTFLOWS_VER ); } } /** * Generate styles. * * @return string */ public function generate_style() { global $post; if ( _is_wcf_checkout_type() ) { $checkout_id = $post->ID; } else { $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content ); } /*Output css variable */ $output = ''; CartFlows_Font_Families::render_fonts( $checkout_id ); $primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' ); $base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' ); $header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' ); /** $base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/ $r = ''; $g = ''; $b = ''; $field_tb_padding = ''; $field_lr_padding = ''; $field_heading_color = ''; $field_color = ''; $field_bg_color = ''; $field_border_color = ''; $field_label_color = ''; $submit_tb_padding = ''; $submit_lr_padding = ''; $hl_bg_color = ''; $field_input_size = ''; $box_border_color = ''; $section_bg_color = ''; $submit_button_height = ''; $submit_color = ''; $submit_bg_color = $primary_color; $submit_border_color = $primary_color; $submit_hover_color = ''; $submit_bg_hover_color = $primary_color; $submit_border_hover_color = $primary_color; $section_heading_color = ''; $is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' ); $button_font_family = ''; $button_font_weight = ''; $input_font_family = ''; $input_font_weight = ''; $heading_font_family = ''; $heading_font_weight = ''; $base_font_family = $base_font_family; /** $base_font_weight = $base_font_weight;*/ if ( 'yes' == $is_advance_option ) { /** * Get Font Family and Font Weight weight values */ $section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' ); $heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' ); $heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' ); $section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' ); $button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' ); $button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' ); $input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' ); $input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' ); $field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' ); $field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' ); $field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' ); $field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' ); $field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' ); $field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' ); $field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' ); $field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' ); $submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' ); $submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' ); $submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' ); $submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color ); $submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color ); $submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color ); $submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' ); $submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color ); $hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' ); $box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' ); $submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' ); /** * Get font values */ if ( 'custom' == $submit_button_height ) { $submit_button_height = '38px'; } if ( 'custom' == $field_input_size ) { $field_input_size = '38px'; } } if ( isset( $primary_color ) ) { list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' ); } if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() || Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $checkout_id ) ) { include CARTFLOWS_CHECKOUT_DIR . 'includes/checkout-dynamic-divi-css.php'; } else { include CARTFLOWS_CHECKOUT_DIR . 'includes/checkout-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_checkout_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_checkout_fields( $order_id, $posted ) { if ( isset( $_POST['_wcf_checkout_id'] ) ) { //phpcs:ignore $checkout_id = wc_clean( intval( $_POST['_wcf_checkout_id'] ) ); //phpcs:ignore update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id ); if ( isset( $_POST['_wcf_flow_id'] ) ) { //phpcs:ignore $flow_id = wc_clean( intval( $_POST['_wcf_flow_id'] ) ); //phpcs:ignore update_post_meta( $order_id, '_wcf_flow_id', $flow_id ); } } } /** * Enable Logo In Header Of Checkout Page * * @return void */ public function enable_logo_in_header() { global $post; if ( _is_wcf_checkout_type() ) { $checkout_id = $post->ID; } else { $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content ); } $header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' ); $add_image_markup = ''; if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) { $add_image_markup = '<div class="wcf-checkout-header-image">'; $add_image_markup .= '<img src="' . $header_logo_image . '" />'; $add_image_markup .= '</div>'; } echo $add_image_markup; } /** * Add text to the bootom of the checkout page. * * @return void */ public function show_cartflows_copyright_message() { $output_string = ''; $output_string .= '<div class="wcf-footer-primary">'; $output_string .= '<div class="wcf-footer-content">'; $output_string .= '<p class="wcf-footer-message">'; $output_string .= 'Checkout powered by CartFlows'; $output_string .= '</p>'; $output_string .= '</div>'; $output_string .= '</div>'; echo $output_string; } /** * 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_checkout_id'] ) ) { //phpcs:ignore $checkout_id = intval( $_POST['_wcf_checkout_id'] ); //phpcs:ignore $redirect = get_permalink( $checkout_id ); } return $redirect; } /** * Display coupon code field after review order fields. */ public function display_custom_coupon_field() { $coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true ); $show_coupon = apply_filters( 'cartflows_show_coupon_field', true ); if ( ! ( $coupon_enabled && $show_coupon ) ) { return; } $coupon_field = array( 'field_text' => __( 'Coupon Code', 'cartflows' ), 'button_text' => __( 'Apply', 'cartflows' ), 'class' => '', ); $coupon_field = apply_filters( 'cartflows_coupon_field_options', $coupon_field ); ob_start(); ?> <div class="wcf-custom-coupon-field <?php echo $coupon_field['class']; ?>" id="wcf_custom_coupon_field"> <div class="wcf-coupon-col-1"> <span> <input type="text" name="coupon_code" class="input-text wcf-coupon-code-input" placeholder="<?php echo $coupon_field['field_text']; ?>" id="coupon_code" value=""> </span> </div> <div class="wcf-coupon-col-2"> <span> <button type="button" class="button wcf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php echo $coupon_field['button_text']; ?></button> </span> </div> </div> <?php echo ob_get_clean(); } /** * Apply filter to change class of remove coupon field. * * @param string $coupon coupon. * @return string */ public function remove_coupon_text( $coupon ) { $coupon = str_replace( 'woocommerce-remove-coupon', 'wcf-remove-coupon', $coupon ); return $coupon; } /** * Apply filter to change the placeholder text of coupon field. * * @return string */ public function coupon_field_placeholder() { return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) ); } /** * Apply filter to change the button text of coupon field. * * @return string */ public function coupon_button_text() { return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) ); } /** * Apply coupon on submit of custom coupon form. */ public function apply_coupon() { $response = ''; check_ajax_referer( 'wcf-apply-coupon', 'security' ); if ( ! empty( $_POST['coupon_code'] ) ) { $result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) ); } else { wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' ); } $response = array( 'status' => $result, 'msg' => wc_print_notices( true ), ); echo wp_json_encode( $response ); die(); } /** * Added ajax nonce to localize variable. * * @param array $vars localize variables. */ public function add_localize_vars( $vars ) { $vars['wcf_validate_coupon_nonce'] = wp_create_nonce( 'wcf-apply-coupon' ); $vars['wcf_validate_remove_coupon_nonce'] = wp_create_nonce( 'wcf-remove-coupon' ); $vars['wcf_validate_remove_cart_product_nonce'] = wp_create_nonce( 'wcf-remove-cart-product' ); $vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' ); return $vars; } /** * Add custom class to the fields to change the UI to three column. * * @param array $fields fields. */ public function add_three_column_layout_fields( $fields ) { if ( empty( $fields['billing']['billing_address_2'] ) ) { if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) { $fields['billing']['billing_address_1']['class'][] = 'form-row-full'; } } if ( ! empty( $fields['billing']['billing_company'] ) ) { if ( isset( $fields['billing']['billing_company'] ) && is_array( $fields['billing']['billing_company'] ) ) { $fields['billing']['billing_company']['class'][] = 'form-row-full'; } } if ( ! empty( $fields['shipping']['shipping_company'] ) ) { if ( isset( $fields['shipping']['shipping_company'] ) && is_array( $fields['shipping']['shipping_company'] ) ) { $fields['shipping']['shipping_company']['class'][] = 'form-row-full'; } } if ( ! empty( $fields['billing']['billing_country'] ) ) { if ( isset( $fields['billing']['billing_country'] ) && is_array( $fields['billing']['billing_country'] ) ) { $fields['billing']['billing_country']['class'][] = 'form-row-full'; } } if ( ! empty( $fields['shipping']['shipping_country'] ) ) { if ( isset( $fields['shipping']['shipping_country'] ) && is_array( $fields['shipping']['shipping_country'] ) ) { $fields['shipping']['shipping_country']['class'][] = 'form-row-full'; } } if ( ! empty( $fields['billing']['billing_phone'] ) ) { if ( isset( $fields['billing']['billing_phone'] ) && is_array( $fields['billing']['billing_phone'] ) ) { $fields['billing']['billing_phone']['class'][] = 'form-row-full'; } } if ( ! empty( $fields['billing']['billing_email'] ) ) { if ( isset( $fields['billing']['billing_email'] ) && is_array( $fields['billing']['billing_email'] ) ) { $fields['billing']['billing_email']['class'][] = 'form-row-full'; } } if ( empty( $fields['shipping']['shipping_address_2'] ) ) { if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) { $fields['shipping']['shipping_address_1']['class'][] = 'form-row-full'; } } if ( isset( $fields['billing']['billing_city'] ) && isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) { $fields['billing']['billing_city']['class'][] = 'wcf-column-33'; $fields['billing']['billing_state']['class'][] = 'wcf-column-33'; $fields['billing']['billing_postcode']['class'][] = 'wcf-column-33'; } if ( isset( $fields['shipping']['shipping_city'] ) && isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) { $fields['shipping']['shipping_city']['class'][] = 'wcf-column-33'; $fields['shipping']['shipping_state']['class'][] = 'wcf-column-33'; $fields['shipping']['shipping_postcode']['class'][] = 'wcf-column-33'; } return $fields; } /** * Add opening dev * * @since 1.0.0 */ public function order_wrap_div_start() { echo "<div class='wcf-order-wrap'> "; } /** * Add closing dev * * @since 1.0.0 */ public function order_wrap_div_end() { echo '</div> '; } /** * Remove coupon. */ public function remove_coupon() { check_ajax_referer( 'wcf-remove-coupon', 'security' ); $coupon = isset( $_POST['coupon_code'] ) ? wc_clean( wp_unslash( $_POST['coupon_code'] ) ) : false; //phpcs:ignore if ( empty( $coupon ) ) { echo "<div class='woocommerce-error'>" . esc_html__( 'Sorry there was a problem removing this coupon.', 'cartflows' ); } else { WC()->cart->remove_coupon( $coupon ); echo "<div class='woocommerce-error'>" . esc_html__( 'Coupon has been removed.', 'cartflows' ) . '</div>'; } wc_print_notices(); wp_die(); } /** * Remove cart item. */ public function wcf_woo_remove_cart_product() { check_ajax_referer( 'wcf-remove-cart-product', 'security' ); $product_key = isset( $_POST['p_key'] ) ? wc_clean( wp_unslash( $_POST['p_key'] ) ) : false; //phpcs:ignore $product_id = isset( $_POST['p_id'] ) ? wc_clean( wp_unslash( $_POST['p_id'] ) ) : ''; //phpcs:ignore $product_title = get_the_title( $product_id ); $needs_shipping = false; if ( empty( $product_key ) ) { $msg = "<div class='woocommerce-message'>" . __( 'Sorry there was a problem removing ', 'cartflows' ) . $product_title; } else { WC()->cart->remove_cart_item( $product_key ); $msg = "<div class='woocommerce-message'>" . $product_title . __( ' has been removed.', 'cartflows' ) . '</div>'; } foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { if ( $values['data']->needs_shipping() ) { $needs_shipping = true; break; } } $response = array( 'need_shipping' => $needs_shipping, 'msg' => $msg, ); echo wp_json_encode( $response ); wp_die(); } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Checkout_Markup::get_instance(); classes/class-cartflows-checkout-meta.php 0000666 00000064023 15214214053 0014556 0 ustar 00 <?php /** * Checkout post meta * * @package CartFlows */ /** * Meta Boxes setup */ class Cartflows_Checkout_Meta extends Cartflows_Meta { /** * Instance * * @var $instance */ private static $instance; /** * Meta Option * * @var $meta_option */ private static $meta_option = null; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor */ public function __construct() { /* Init Metabox */ add_action( 'load-post.php', array( $this, 'init_metabox' ) ); add_action( 'load-post-new.php', array( $this, 'init_metabox' ) ); } /** * Init Metabox */ public function init_metabox() { add_action( 'add_meta_boxes', array( $this, 'setup_meta_box' ) ); add_action( 'save_post', array( $this, 'save_meta_box' ) ); } /** * Setup Metabox */ public function setup_meta_box() { if ( _is_wcf_checkout_type() ) { add_meta_box( 'wcf-checkout-settings', // Id. __( 'Checkout Layout', 'cartflows' ), // Title. array( $this, 'markup_meta_box' ), // Callback. wcf()->utils->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-checkout-step-meta', 'nonce-checkout-step-meta' ); $stored = get_post_meta( $post->ID ); $checkout_meta = self::get_meta_option( $post->ID ); // Set stored and override defaults. foreach ( $stored as $key => $value ) { if ( array_key_exists( $key, $checkout_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 ); $checkout_data = array(); foreach ( $meta as $key => $value ) { $checkout_data[ $key ] = $meta[ $key ]['default']; } /** $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post->ID ); // For loop foreach ( $billing_fields as $key => $value ) { $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default']; } $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post->ID ); foreach ( $shipping_fields as $key => $value ) { $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default']; } $additional_fields = Cartflows_Helper::get_checkout_fields( 'additional', $post->ID ); foreach ( $additional_fields as $key => $value ) { $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default']; } */ do_action( 'wcf_checkout_settings_markup_before' ); $this->tabs_markup( $checkout_data, $post->ID ); do_action( 'wcf_checkout_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-checkout-shortcodes'; } $tab_array = array( array( 'title' => __( 'Shortcodes', 'cartflows' ), 'id' => 'wcf-checkout-shortcodes', 'class' => 'wcf-checkout-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-editor-code', ), array( 'title' => __( 'Select Product', 'cartflows' ), 'id' => 'wcf-checkout-general', 'class' => 'wcf-checkout-general' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-info', ), array( 'title' => __( 'Order Bump', 'cartflows' ), 'id' => 'wcf-product-order-bump', 'class' => 'wcf-product-order-bump' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-cart', ), array( 'title' => __( 'Checkout Offer', 'cartflows' ), 'id' => 'wcf-pre-checkout-offer', 'class' => 'wcf-pre-checkout-offer' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-arrow-up-alt', ), array( 'title' => __( 'Checkout Design', 'cartflows' ), 'id' => 'wcf-checkout-style', 'class' => 'wcf-checkout-style' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-admin-customizer', ), array( 'title' => __( 'Checkout Fields', 'cartflows' ), 'id' => 'wcf-checkout-custom-fields', 'class' => 'wcf-checkout-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-welcome-widgets-menus', ), array( 'title' => __( 'Checkout Settings', 'cartflows' ), 'id' => 'wcf-checkout-custom-settings', 'class' => 'wcf-checkout-custom-settings' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-admin-generic', ), array( 'title' => __( 'Custom Script', 'cartflows' ), 'id' => 'wcf-checkout-custom-script-header', 'class' => 'wcf-checkout-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-format-aside', ), ); $show_logo = filter_input( INPUT_GET, 'logo-tab', FILTER_VALIDATE_BOOLEAN ); if ( $show_logo ) { $logo_tab = array( 'title' => __( 'Logo (Optional)', 'cartflows' ), 'id' => 'wcf-checkout-header', 'class' => 'wcf-checkout-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-format-image', ); array_push( $tab_array, $logo_tab ); } $tabs = apply_filters( 'cartflows_checkout_tabs', $tab_array, $active_tab ); ?> <div class="wcf-checkout-table wcf-metabox-wrap widefat"> <div class="wcf-table-container"> <div class="wcf-column-left"> <div class="wcf-tab-wrapper"> <?php foreach ( $tabs as $key => $tab ) { ?> <div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>"> <span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span> <span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span> </div> <?php } ?> <input type="hidden" id="wcf-active-tab" name="wcf-active-tab" value="<?php echo esc_attr( $active_tab ); ?>" /> </div> </div> <div class="wcf-column-right"> <?php $this->tab_shortcodes( $options, $post_id ); ?> <?php $this->tab_general( $options, $post_id ); ?> <?php $this->tab_style( $options, $post_id ); ?> <?php $this->tab_pre_checkout_offer( $options, $post_id ); ?> <?php $this->tab_product_bump( $options, $post_id ); ?> <?php $this->tab_custom_fields( $options, $post_id ); ?> <?php $this->tab_custom_settings( $options, $post_id ); ?> <?php $this->tab_header_content( $options, $post_id ); ?> <?php $this->tab_custom_script( $options, $post_id ); ?> <?php do_action( 'cartflows_checkout_tabs_content', $options, $post_id ); ?> <?php $this->right_column_footer( $options, $post_id ); ?> </div> </div> </div> <?php } /** * Shortcodes tab * * @param array $options options. * @param int $post_id post ID. */ public function tab_shortcodes( $options, $post_id ) { ?> <div class="wcf-checkout-shortcodes wcf-tab-content widefat"> <?php echo wcf()->meta->get_shortcode_field( array( 'label' => 'Checkout Page', 'name' => 'wcf-checkout-shortcode', 'content' => '[cartflows_checkout]', 'help' => esc_html__( 'Add this shortcode to your checkout page', 'cartflows' ), ) ); ?> </div> <?php } /** * General tab * * @param array $options options. * @param int $post_id post ID. */ public function tab_general( $options, $post_id ) { ?> <div class="wcf-checkout-general wcf-tab-content widefat"> <?php echo wcf()->meta->get_product_selection_repeater( array( 'name' => 'wcf-checkout-products', 'value' => $options['wcf-checkout-products'], 'allow_clear' => true, ) ); if ( ! _is_cartflows_pro() ) { echo wcf()->meta->get_hr_line_field( array() ); echo wcf()->meta->get_description_field( array( 'name' => 'wcf-upgrade-to-pro', /* translators: %s: link */ 'content' => '<i>' . sprintf( esc_html__( 'Upgrade to %1$sCartFlows Pro%2$s for Pre-applied Coupon, Product Variations & Quantity Options.', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>', ) ); } do_action( 'cartflows_checkout_general_tab_content', $options, $post_id ); ?> </div> <?php } /** * Pre Checkout tab * * @param array $options options. * @param int $post_id post ID. */ public function tab_pre_checkout_offer( $options, $post_id ) { ?> <div class="wcf-pre-checkout-offer wcf-tab-content widefat"> <?php if ( ! _is_cartflows_pro() ) { echo wcf()->meta->get_description_field( array( 'name' => 'wcf-upgrade-to-pro', /* translators: %s: link */ 'content' => '<i>' . sprintf( esc_html__( 'Upgrade to %1$sCartFlows Pro%2$s for Checkout Offer feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>', ) ); } elseif ( _is_cartflows_pro_ver_less_than( '1.2.0' ) ) { $version = '1.2.0'; echo wcf()->meta->get_description_field( array( 'name' => 'wcf-upgrade-to-pro', /* translators: %s: link */ 'content' => '<i>' . sprintf( esc_html__( 'Update to %1$sCartFlows Pro%2$s to %3$s or above for Checkout Offer feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>', $version ) . '</i>', ) ); } ?> <?php do_action( 'cartflows_pre_checkout_offer_tab_content', $options, $post_id ); ?> </div> <?php } /** * Pre Checkout tab * * @param array $options options. * @param int $post_id post ID. */ public function animate_title_settings( $options, $post_id ) { echo wcf()->meta->get_hr_line_field( array() ); if ( ! _is_cartflows_pro() ) { echo wcf()->meta->get_description_field( array( 'name' => 'wcf-upgrade-to-pro', /* translators: %s: link */ 'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for animate browser tab feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>', ) ); } elseif ( _is_cartflows_pro_ver_less_than( '1.4.0' ) ) { $version = '1.4.0'; echo wcf()->meta->get_description_field( array( 'name' => 'wcf-upgrade-to-pro', /* translators: %s: link */ 'content' => '<i>' . sprintf( __( 'Update to %1$sCartFlows Pro%2$s to %3$s or above for animate browser tab feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>', $version ) . '</i>', ) ); } do_action( 'cartflows_animate_browser_tab_settings', $options, $post_id ); } /** * Product bump tab * * @param array $options options. * @param int $post_id post ID. */ public function tab_product_bump( $options, $post_id ) { ?> <div class="wcf-product-order-bump wcf-tab-content widefat"> <?php if ( ! _is_cartflows_pro() ) { echo wcf()->meta->get_description_field( array( 'name' => 'wcf-upgrade-to-pro', /* translators: %s: link */ 'content' => '<i>' . sprintf( esc_html__( 'Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature.', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>', ) ); } ?> <?php do_action( 'cartflows_order_bump_tab_content', $options, $post_id ); ?> </div> <?php } /** * Tab custom fields * * @param array $options options. * @param int $post_id post ID. */ public function tab_custom_fields( $options, $post_id ) { ?> <div class="wcf-checkout-custom-fields wcf-tab-content widefat"> <?php /* Custom Checkout Fields Section */ if ( ! _is_cartflows_pro() ) { echo wcf()->meta->get_description_field( array( 'name' => 'wcf-upgrade-to-pro', /* translators: %s: link */ 'content' => '<i>' . sprintf( esc_html__( 'Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature.', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>', ) ); } ?> <?php do_action( 'cartflows_custom_fields_tab_content', $options, $post_id ); ?> </div> <?php } /** * Tab custom settings * * @param array $options options. * @param int $post_id post ID. */ public function tab_custom_settings( $options, $post_id ) { ?> <div class="wcf-checkout-custom-settings wcf-tab-content widefat"> <div class="wcf-custom-settings-fields"> <?php echo wcf()->meta->get_text_field( array( 'label' => __( 'Place Order Button Text', 'cartflows' ), 'name' => 'wcf-checkout-place-order-button-text', 'value' => $options['wcf-checkout-place-order-button-text'], 'attr' => array( 'placeholder' => __( 'Place order', 'cartflows' ), ), 'help' => __( 'It will change the Place Order Button text on checkout page.', 'cartflows' ), ) ); echo wcf()->meta->get_hr_line_field( array() ); echo wcf()->meta->get_checkbox_field( array( 'name' => 'wcf-remove-product-field', 'value' => $options['wcf-remove-product-field'], 'after' => esc_html__( 'Enable cart editing on checkout', 'cartflows' ), ) ); echo wcf()->meta->get_description_field( array( 'name' => '', /* translators: %s: link */ 'content' => '<i>' . sprintf( esc_html__( 'Users will able to remove products from the checkout page.', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>', ) ); $this->animate_title_settings( $options, $post_id ); ?> </div> <?php do_action( 'cartflows_custom_settings_tab_content', $options, $post_id ); ?> </div> <?php } /** * Tab style * * @param array $options options. * @param int $post_id post ID. */ public function tab_style( $options, $post_id ) { ?> <div class="wcf-checkout-style wcf-tab-content widefat"> <div class="wcf-cs-fields"> <div class="wcf-cs-checkbox-field"> <?php $layout_pro_option = array(); if ( ! _is_cartflows_pro() ) { $layout_pro_option = array( 'one-column' => __( 'One Column (Available in CartFlows Pro) ', 'cartflows' ), 'two-step' => __( 'Two Step (Available in CartFlows Pro) ', 'cartflows' ), ); } echo wcf()->meta->get_select_field( array( 'label' => __( 'Checkout Skin', 'cartflows' ), 'name' => 'wcf-checkout-layout', 'value' => $options['wcf-checkout-layout'], 'options' => array( 'one-column' => esc_html__( 'One Column', 'cartflows' ), 'two-column' => esc_html__( 'Two Column', 'cartflows' ), 'two-step' => esc_html__( 'Two Step', 'cartflows' ), ), 'pro-options' => $layout_pro_option, ) ); echo wcf()->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'], ) ); echo wcf()->meta->get_checkbox_field( array( 'label' => __( 'Advance Options', 'cartflows' ), 'name' => 'wcf-advance-options-fields', 'value' => $options['wcf-advance-options-fields'], 'after' => 'Enable', ) ); ?> </div> <div class="wcf-cs-fields-options"> <?php echo wcf()->meta->get_section( array( 'label' => __( 'Heading', 'cartflows' ), ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Heading Color', 'cartflows' ), 'name' => 'wcf-heading-color', 'value' => $options['wcf-heading-color'], ) ); echo wcf()->meta->get_font_family_field( array( 'for' => 'wcf-heading', 'label' => esc_html__( 'Font Family', 'cartflows' ), 'name' => 'wcf-heading-font-family', 'value' => $options['wcf-heading-font-family'], ) ); echo wcf()->meta->get_font_weight_field( array( 'for' => 'wcf-heading', 'label' => esc_html__( 'Font Weight', 'cartflows' ), 'name' => 'wcf-heading-font-weight', 'value' => $options['wcf-heading-font-weight'], ) ); echo wcf()->meta->get_section( array( 'label' => __( 'Input Fields', 'cartflows' ), ) ); $fields_skin_pro_option = array(); if ( ! _is_cartflows_pro() ) { $fields_skin_pro_option = array( 'style-one' => __( 'Floating Labels (Available in CartFlows Pro)', 'cartflows' ), ); } echo wcf()->meta->get_select_field( array( 'label' => __( 'Style', 'cartflows' ), 'name' => 'wcf-fields-skins', 'value' => $options['wcf-fields-skins'], 'options' => array( 'default' => esc_html__( 'Default', 'cartflows' ), 'style-one' => 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' => __( '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'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Label Color', 'cartflows' ), 'name' => 'wcf-field-label-color', 'value' => $options['wcf-field-label-color'], ) ); ?> </div> <div class="wcf-cs-button-options"> <?php echo wcf()->meta->get_section( array( 'label' => __( 'Buttons', 'cartflows' ), ) ); 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-input-button-size', 'value' => $options['wcf-input-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_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'], ) ); ?> </div> <div class="wcf-cs-section-options"> <?php echo wcf()->meta->get_section( array( 'label' => __( 'Sections', 'cartflows' ), ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Highlight Area Background Color', 'cartflows' ), 'name' => 'wcf-hl-bg-color', 'value' => $options['wcf-hl-bg-color'], ) ); echo wcf()->meta->get_hidden_field( array( 'name' => 'wcf-field-google-font-url', 'value' => $options['wcf-field-google-font-url'], ) ); ?> </div> <?php do_action( 'cartflows_checkout_style_tab_content', $options, $post_id ); ?> </div> </div> <?php } /** * Tab Header (Used for add logo into header) * * @param array $options options. * @param int $post_id post ID. */ public function tab_header_content( $options, $post_id ) { ?> <div class="wcf-checkout-header wcf-tab-content widefat"> <?php $layout_pro_option = array(); echo wcf()->meta->get_image_field( array( 'name' => 'wcf-header-logo-image', 'value' => $options['wcf-header-logo-image'], 'label' => esc_html__( 'Header Logo', 'cartflows' ), ) ); echo wcf()->meta->get_number_field( array( 'name' => 'wcf-header-logo-width', 'value' => $options['wcf-header-logo-width'], 'label' => esc_html__( 'Logo Width (In px)', 'cartflows' ), ) ); ?> <?php do_action( 'cartflows_checkout_header_tab_content', $options, $post_id ); ?> </div> <?php } /** * Get metabox options * * @param int $post_id post ID. */ public static function get_meta_option( $post_id ) { if ( null === self::$meta_option ) { /** * Set metabox options * * @see http://php.net/manual/en/filter.filters.sanitize.php */ self::$meta_option = wcf()->options->get_checkout_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-checkout-step-meta'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce-checkout-step-meta'] ) ), 'save-nonce-checkout-step-meta' ) ) ? true : false; // Exits script depending on save status. if ( $is_autosave || $is_revision || ! $is_valid_nonce ) { return; } wcf()->options->save_checkout_fields( $post_id ); } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Checkout_Meta::get_instance(); templates/wcf-template.php 0000666 00000002550 15214214053 0011646 0 ustar 00 <?php /** * Flow * * @package CartFlows */ ?> <!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <meta name="robots" content="noindex"> <title><?php wp_title( '-', true, 'right' ); ?><?php bloginfo( 'name' ); ?></title> <link rel="profile" href="http://gmpg.org/xfn/11" /> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <div class="wrapper"> <header class="header"> </header> <div class="main-container"> <div class="checkout-forms"> <!-- CHECKOUT SHORTCODE --> <?php $checkout_html = do_shortcode( '[woocommerce_checkout]' ); if ( empty( $checkout_html ) || trim( $checkout_html ) == '<div class="woocommerce"></div>' ) { echo esc_html__( 'Your cart is currently empty.', 'cartflows' ); } else { echo $checkout_html; } ?> <!-- END CHECKOUT SHORTCODE --> </div> </div> <footer class="footer"> <p><?php esc_html_e( 'Copyright ©', 'cartflows' ); ?> <?php echo gmdate( 'Y' ); echo ' ' . get_bloginfo( 'name' ); ?> - <?php esc_html_e( 'All Rights Reserved', 'cartflows' ); ?></p> </footer> </div> <div class="wcf-hide"> <?php wp_footer(); ?> </div> </body> </html> templates/embed/checkout-template-simple.php 0000666 00000001711 15214214053 0015235 0 ustar 00 <?php /** * Checkout template * * @package CartFlows */ $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' ); $fields_skins = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-fields-skins' ); ?> <div id="wcf-embed-checkout-form" class="wcf-embed-checkout-form wcf-embed-checkout-form-<?php echo $checkout_layout; ?> wcf-field-<?php echo $fields_skins; ?>"> <!-- CHECKOUT SHORTCODE --> <?php do_action( 'cartflows_add_before_main_section', $checkout_layout ); ?> <?php $checkout_html = do_shortcode( '[woocommerce_checkout]' ); if ( empty( $checkout_html ) || trim( $checkout_html ) == '<div class="woocommerce"></div>' ) { do_action( 'cartflows_checkout_cart_empty', $checkout_id ); echo esc_html__( 'Your cart is currently empty.', 'cartflows' ); } else { echo $checkout_html; } ?> <?php do_action( 'cartflows_add_after_main_section', $arg = '' ); ?> <!-- END CHECKOUT SHORTCODE --> </div>
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings