id = 'shareyourcart'; $this->method_title = __( 'ShareYourCart', 'woocommerce' ); $this->method_description = sprintf( __( 'Increase your social media exposure by 10 percent! ShareYourCart helps you get more customers by motivating satisfied customers to talk with their friends about your products. For help with ShareYourCart view the documentation.', 'woocommerce' ), 'http://www.woothemes.com/woocommerce-docs/user-guide/shareyourcart/' ); // Load the form fields. $this->init_form_fields(); // Load the settings. $this->init_settings(); // Define user set variables $this->enabled = $this->settings['enabled']; $this->client_id = $this->settings['client_id']; $this->app_key = $this->settings['app_key']; $this->email = $this->settings['email']; // Actions add_action( 'woocommerce_update_options_integration_shareyourcart', array( &$this, 'process_admin_options') ); add_action( 'woocommerce_update_options_integration_shareyourcart', array( &$this, 'process_forms') ); // Actions if enabled if ( $this->enabled == 'yes' ) { add_action( 'wp_enqueue_scripts', array(&$this, 'styles') ); $this->init_share_your_cart(); } } /** * styles function. * * @access public * @return void */ public function styles() { wp_enqueue_style( 'shareyourcart', plugins_url( 'css/style.css', __FILE__ ) ); } /** * init_share_your_cart function. * * @access public * @return void */ function init_share_your_cart() { if ( empty( $this->shareYourCartWooCommerce ) ) { // Share your cart api class include_once('class-shareyourcart-woocommerce.php'); // Init the class $this->shareYourCartWooCommerce = new ShareYourCartWooCommerce( $this->settings ); } } /** * process_forms function. * * @access public */ function process_forms() { if ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'create' ) { $this->init_share_your_cart(); $error = $message = ''; $redirect = remove_query_arg( 'saved' ); $redirect = remove_query_arg( 'wc_error', $redirect ); $redirect = remove_query_arg( 'wc_message', $redirect ); if ( ! empty( $_POST['domain'] ) && ! empty( $_POST['email'] ) && ! empty( $_POST['syc-terms-agreement'] ) ) { if ( ! ( ( $register = $this->shareYourCartWooCommerce->register( $this->shareYourCartWooCommerce->getSecretKey(), $_POST['domain'], $_POST['email'], $message ) ) === false) ) { $this->shareYourCartWooCommerce->setConfigValue('app_key', $register['app_key']); $this->shareYourCartWooCommerce->setConfigValue('client_id', $register['client_id']); $redirect = remove_query_arg( 'syc-account', $redirect ); } else { $error = $message; if ( json_decode($error) ) { $error = json_decode($error); $error = $error->message; } $message = ''; } } else { $error = __( 'Please complete all fields.', 'woocommerce' ); } if ( $error ) $redirect = add_query_arg( 'wc_error', urlencode( esc_attr( $error ) ), $redirect ); if ( $message ) $redirect = add_query_arg( 'wc_message', urlencode( esc_attr( $message ) ), $redirect ); wp_safe_redirect( $redirect ); exit; } elseif ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'recover' ) { $this->init_share_your_cart(); $error = $message = ''; $redirect = remove_query_arg( 'saved' ); $redirect = remove_query_arg( 'wc_error', $redirect ); $redirect = remove_query_arg( 'wc_message', $redirect ); if ( ! empty( $_POST['domain'] ) && ! empty( $_POST['email'] ) ) { if ( ! $this->shareYourCartWooCommerce->recover( $this->shareYourCartWooCommerce->getSecretKey(), $_POST['domain'], $_POST['email'], $message ) ) { $error = $message; if ( json_decode($error) ) { $error = json_decode($error); $error = $error->message; } $message = ''; } else { $redirect = remove_query_arg( 'syc-account', $redirect ); } } else { $error = __( 'Please complete all fields.', 'woocommerce' ); } if ( $error ) $redirect = add_query_arg( 'wc_error', urlencode( esc_attr( $error ) ), $redirect ); if ( $message ) $redirect = add_query_arg( 'wc_message', urlencode( esc_attr( $message ) ), $redirect ); wp_safe_redirect( $redirect ); exit; } } /** * Admin Options * * Setup the gateway settings screen. * Override this in your gateway. * * @since 1.0.0 */ function admin_options() { if ( $this->enabled == 'yes' ) { // Installation $this->shareYourCartWooCommerce->install(); // Check status $this->shareYourCartWooCommerce->admin_settings_page(); } ?> client_id && ! $this->app_key ) { if ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'create' ) { ?>