function yith_ywraq_constructor()
{
    // Woocommerce installation check _________________________
    if (!function_exists('WC')) {
        function yith_ywraq_install_woocommerce_admin_notice()
        {
            ?>
            <div class="error">
                <p><?php 
            _e('YITH Woocommerce Request A Quote is enabled but not effective. It requires WooCommerce in order to work.', 'yith-woocommerce-request-a-quote');
            ?>
</p>
            </div>
        <?php 
        }
        add_action('admin_notices', 'yith_ywraq_install_woocommerce_admin_notice');
        return;
    }
    // Load YWCM text domain ___________________________________
    load_plugin_textdomain('yith-woocommerce-request-a-quote', false, dirname(plugin_basename(__FILE__)) . '/languages/');
    // Load required classes and functions
    if (!class_exists('WC_Session')) {
        include_once WC()->plugin_path() . '/includes/abstracts/abstract-wc-session.php';
    }
    require_once YITH_YWRAQ_INC . 'functions.yith-request-quote.php';
    require_once YITH_YWRAQ_INC . 'class.yith-ywraq-session.php';
    require_once YITH_YWRAQ_INC . 'class.yith-ywraq-shortcodes.php';
    require_once YITH_YWRAQ_INC . 'class.yith-request-quote.php';
    if (is_admin()) {
        require_once YITH_YWRAQ_INC . 'class.yith-request-quote-admin.php';
    } else {
        require_once YITH_YWRAQ_INC . 'class.yith-request-quote-frontend.php';
        YITH_YWRAQ_Frontend();
    }
    YITH_Request_Quote();
}
 public function request_quote_list($atts, $content = null)
 {
     $raq_content = YITH_Request_Quote()->get_raq_return();
     $args = array('raq_content' => $raq_content, 'template_part' => 'view');
     $args['args'] = $args;
     ob_start();
     yit_plugin_get_template(YITH_YWRAQ_DIR, 'request-quote.php', $args);
     return ob_get_clean();
 }
 /**
  * Method triggered to send email
  *
  * @param int $args
  *
  * @return void
  * @since  1.0
  * @author Emanuela Castorina <*****@*****.**>
  */
 public function trigger($args)
 {
     $this->raq = $args;
     $this->raq['raq_content'] = YITH_Request_Quote()->get_raq_return();
     $return = $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
     if ($return) {
         YITH_Request_Quote()->clear_raq_list();
         yith_ywraq_add_notice(__('Your request has been sent successfully', 'ywraq'), 'success');
     } else {
         yith_ywraq_add_notice(__('There was a problem in sending your request. Please try again.', 'ywraq'), 'error');
     }
 }
 /**
  * Update the Request Quote List
  *
  * @return void
  * @since  1.0.0
  * @author Emanuela Castorina
  */
 public function update_raq_list()
 {
     if (isset($_POST['update_raq_wpnonce']) && isset($_POST['raq']) && wp_verify_nonce($_POST['update_raq_wpnonce'], 'update-request-quote-quantity')) {
         foreach ($_POST['raq'] as $key => $value) {
             if ($value['qty'] != 0) {
                 YITH_Request_Quote()->update_item($key, 'quantity', $value['qty']);
             } else {
                 YITH_Request_Quote()->remove_item($key);
             }
         }
     }
 }
예제 #5
0
 *
 * @package YITH Woocommerce Request A Quote
 * @since   1.0.0
 * @author  Yithemes
 */
if (count($raq_content) == 0) {
    ?>
	<p><?php 
    _e('No products in list', 'yith-woocommerce-request-a-quote');
    ?>
</p>
<?php 
} else {
    ?>
    <form id="yith-ywraq-form" name="yith-ywraq-form" action="<?php 
    echo esc_url(YITH_Request_Quote()->get_raq_page_url('update'));
    ?>
" method="post">
	<table class="shop_table cart" id="yith-ywrq-table-list" cellspacing="0">
        <thead>
            <tr>
                <th class="product-remove">&nbsp;</th>
                <th class="product-thumbnail">&nbsp;</th>
                <th class="product-name"><?php 
    _e('Product', 'yith-woocommerce-request-a-quote');
    ?>
</th>
                <th class="product-quantity"><?php 
    _e('Quantity', 'yith-woocommerce-request-a-quote');
    ?>
</th>
예제 #6
0
 /**
  * Get all errors in HTML mode or simple string.
  *
  * @return void
  * @since 1.0.0
  */
 public function send_message()
 {
     if (!isset($_POST['rqa_name'])) {
         return;
     }
     $errors = array();
     if (isset($_POST['raq_mail_wpnonce']) && wp_verify_nonce($_POST['raq_mail_wpnonce'], 'send-request-quote')) {
         $regex = '/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/';
         if (empty($_POST['rqa_name'])) {
             $errors[] = '<p>' . __('Please enter a name', 'yith-woocommerce-request-a-quote') . '</p>';
         }
         if (!isset($_POST['rqa_email']) || empty($_POST['rqa_email']) || !preg_match($regex, $_POST['rqa_email'])) {
             $errors[] = '<p>' . __('Please enter a valid email', 'yith-woocommerce-request-a-quote') . '</p>';
         }
         if (YITH_Request_Quote()->is_empty()) {
             $errors[] = '<p>' . __('Your list is empty, add products to the list to send a request', 'yith-woocommerce-request-a-quote') . '</p>';
         }
         if (empty($errors)) {
             $args = array('user_name' => $_POST['rqa_name'], 'user_email' => $_POST['rqa_email'], 'user_message' => nl2br($_POST['rqa_message']), 'raq_content' => YITH_Request_Quote()->get_raq_return());
             do_action('ywraq_process', $args);
             do_action('send_raq_mail', $args);
             wp_redirect(YITH_Request_Quote()->get_raq_page_url(), 301);
             exit;
         }
     } else {
         $errors[] = '<p>' . __('There was a problem in sending your request. Please try again.', 'yith-woocommerce-request-a-quote') . '</p>';
     }
     yith_ywraq_add_notice($this->get_errors($errors), 'error');
 }
예제 #7
0
 /**
  * YITH Plugins support
  *
  * @return string
  * @since 1.0
  */
 function yit_plugins_support()
 {
     /* === YITH WooCommerce Multi Vendor */
     if (class_exists('YITH_Vendors_Frontend_Premium') && function_exists('YITH_Vendors')) {
         $obj = YITH_Vendors()->frontend;
         remove_action('woocommerce_archive_description', array($obj, 'add_store_page_header'));
         add_action('yith_before_shop_page_meta', array($obj, 'add_store_page_header'));
         add_filter('yith_wpv_quick_info_button_class', 'yith_multi_vendor_button_class');
         add_filter('yith_wpv_report_abuse_button_class', 'yith_multi_vendor_button_class');
     }
     if (!function_exists('yith_multi_vendor_quick_info_button_class')) {
         /**
          * YITH Plugins support -> Multi Vendor widgets submit button
          *
          * @param string $class
          * @return string
          * @since 1.0
          */
         function yith_multi_vendor_button_class($class)
         {
             return 'button btn-flat pull-right';
         }
     }
     /* === YITH WooCommerce Advanced Review */
     if (defined('YITH_YWAR_VERSION')) {
         global $YWAR_AdvancedReview;
         remove_action('yith_advanced_reviews_before_reviews', array($YWAR_AdvancedReview, 'load_reviews_summary'));
         add_action('yith_advanced_reviews_before_review_list', array($YWAR_AdvancedReview, 'load_reviews_summary'));
     }
     if (defined('YITH_YWAR_PREMIUM')) {
         add_filter('yith_advanced_reviews_loader_gif', 'yit_loading_search_icon');
     }
     /* Request a Quote */
     if (defined('YITH_YWRAQ_VERSION')) {
         $yith_request_quote = YITH_Request_Quote();
         if (method_exists($yith_request_quote, 'add_button_shop')) {
             remove_action('woocommerce_after_shop_loop_item', array($yith_request_quote, 'add_button_shop'), 15);
             add_action('woocommerce_before_shop_loop_item', array($yith_request_quote, 'add_button_shop'), 30);
         }
         add_filter('ywraq_product_in_list', 'yit_ywraq_change_product_in_list_message');
         function yit_ywraq_change_product_in_list_message()
         {
             return __('In your quote list', 'yit');
         }
         add_filter('ywraq_product_added_view_browse_list', 'yit_ywraq_product_added_view_browse_list_message');
         function yit_ywraq_product_added_view_browse_list_message()
         {
             return __('View list &gt;', 'yit');
         }
         add_filter('yith_admin_tab_params', 'yith_wraq_remove_layout_options');
         if (!function_exists('yith_wraq_remove_layout_options')) {
             /**
              * Remove Layout option from Request a Quote
              *
              * @param array $array
              * @return array
              * @since 1.0
              */
             function yith_wraq_remove_layout_options($array)
             {
                 if ($array['page'] == 'yith_woocommerce_request_a_quote') {
                     unset($array['available_tabs']['layout']);
                 }
                 return $array;
             }
         }
     }
     /*================ Colors and Label Variations Premium ==================*/
     if (defined('YITH_WCCL_PREMIUM') && function_exists('YITH_WCCL_Frontend')) {
         remove_filter('woocommerce_loop_add_to_cart_link', array(YITH_WCCL_Frontend(), 'add_select_options'), 99, 2);
         add_action('woocommerce_after_shop_loop_item_title', array(YITH_WCCL_Frontend(), 'print_select_options'), 99);
         if (yit_get_option('shop-layout-type') == 'slideup') {
             add_filter('yith_wccl_add_to_cart_button_content', 'yit_get_add_to_cart_slideup');
         }
         function yit_get_add_to_cart_slideup($arg)
         {
             $img = yit_get_option('shop-slide-add-cart-icon') != '' ? yit_get_option('shop-slide-add-cart-icon') : get_template_directory_uri() . '/images/ico-cart.png';
             $image_size = yit_getimagesize($img);
             $button = '<img src="' . $img . '" alt="ico-cart" class="ico-cart" height="' . $image_size[1] . '" width="' . $image_size[0] . '"/>';
             return $button;
         }
     }
     /* === WPML === */
     function yit_wpml_endpoint_hack_for_after()
     {
         global $yit_wpml_hack_endpoint;
         $yit_wpml_hack_endpoint = WC()->query->query_vars;
         // add the options
         foreach ($yit_wpml_hack_endpoint as $endpoint => $value) {
             add_option('woocommerce_myaccount_' . $endpoint . '_endpoint', $value);
         }
     }
     add_action('after_setup_theme', 'yit_wpml_endpoint_hack_for_after', 11);
     function yit_wpml_my_account_endpoint()
     {
         global $woocommerce_wpml, $yit_wpml_hack_endpoint;
         if (!isset($woocommerce_wpml->endpoints)) {
             return;
         }
         $endpoints = array('recent-downloads', 'myaccount-wishlist');
         $wc_vars = WC()->query->query_vars;
         foreach ($endpoints as $endpoint) {
             if (!isset($yit_wpml_hack_endpoint[$endpoint])) {
                 return;
             }
             $wc_vars_endpoint = isset($wc_vars[$endpoint]) ? $wc_vars[$endpoint] : $endpoint;
             WC()->query->query_vars[$endpoint] = $woocommerce_wpml->endpoints->get_endpoint_translation($yit_wpml_hack_endpoint[$endpoint], $wc_vars_endpoint);
         }
         unset($yit_wpml_hack_endpoint);
     }
     add_action('init', 'yit_wpml_my_account_endpoint', 3);
 }
예제 #8
0
    /**
     * YITH Plugins support
     *
     * @return string
     * @since 1.0
     */
    function yit_plugins_support(){

        /* === YITH WooCommerce Multi Vendor */
        if( class_exists( 'YITH_Vendors_Frontend_Premium' ) && function_exists( 'YITH_Vendors' ) ){
            $obj = YITH_Vendors()->frontend;
            remove_action( 'woocommerce_archive_description', array( $obj, 'add_store_page_header' ) );
            add_action( 'yith_before_shop_page_meta', array( $obj, 'add_store_page_header' ) );

            add_filter( 'yith_wpv_quick_info_button_class', 'yith_multi_vendor_button_class' );
            add_filter( 'yith_wpv_report_abuse_button_class', 'yith_multi_vendor_button_class' );
        }

        if ( ! function_exists( 'yith_multi_vendor_quick_info_button_class' ) ) {

            /**
             * YITH Plugins support -> Multi Vendor widgets submit button
             *
             * @param string $class
             * @return string
             * @since 1.0
             */
            function yith_multi_vendor_button_class( $class ) {
                return 'btn btn-flat alignright';
            }
        }


        /* === YITH WooCommerce Advanced Review */

        if ( defined( 'YITH_YWAR_PREMIUM' ) ) {
            add_filter( 'yith_advanced_reviews_loader_gif', 'yit_loading_search_icon' );
        }


        /* Request a Quote */

        if ( defined( 'YITH_YWRAQ_VERSION' ) ) {

            $yith_request_quote = YITH_Request_Quote();

            if ( method_exists( $yith_request_quote, 'add_button_shop' ) ) {
                remove_action( 'woocommerce_after_shop_loop_item', array( $yith_request_quote, 'add_button_shop' ), 15 );
                add_action( 'woocommerce_after_shop_loop_item_title', array( $yith_request_quote, 'add_button_shop' ), 30);
            }

            add_filter( 'ywraq_product_in_list', 'yit_ywraq_change_product_in_list_message' );

            function yit_ywraq_change_product_in_list_message() {
                return __( 'In your quote list', 'yit' );
            }

            add_filter( 'ywraq_product_added_view_browse_list', 'yit_ywraq_product_added_view_browse_list_message' );

            function yit_ywraq_product_added_view_browse_list_message() {
                return __( 'View list &gt;', 'yit' );
            }

            add_filter( 'yith_admin_tab_params' , 'yith_wraq_remove_layout_options' );

            if ( ! function_exists( 'yith_wraq_remove_layout_options' ) ) {

                /**
                 * Remove Layout option from Request a Quote
                 *
                 * @param array $array
                 * @return array
                 * @since 1.0
                 */
                function yith_wraq_remove_layout_options( $array ) {

                    if ( $array['page'] == 'yith_woocommerce_request_a_quote' ) {
                        unset( $array['available_tabs']['layout'] );
                    }

                    return $array;
                }
            }
        }

        // Catalog Mode


        if ( defined( 'YWCTM_PREMIUM' ) ) {

            global $YITH_WC_Catalog_Mode;

            remove_action( 'woocommerce_before_shop_loop_item_title', array( $YITH_WC_Catalog_Mode, 'hide_add_to_cart_loop' ), 5 );

            add_action( 'woocommerce_before_shop_loop_item_title', 'yit_rg_hide_add_to_cart_loop', 10 );
        }

        function yit_rg_hide_add_to_cart_loop() {
            global $YITH_WC_Catalog_Mode;
            if ( isset( $YITH_WC_Catalog_Mode ) ) {

                if ( method_exists( $YITH_WC_Catalog_Mode, 'check_hide_add_cart_loop' ) ) {

                    global $woocommerce_loop;

                    if ( ! isset( $woocommerce_loop['products_layout'] ) || $woocommerce_loop['products_layout'] == 'elegant' || $woocommerce_loop['products_layout'] == 'default' ) {
                        if ( $YITH_WC_Catalog_Mode->check_hide_add_cart_loop() ) {
                            remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 20 );
                        }
                        else {
                            add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 20 );
                        }
                    }
                    else {
                        if ( $woocommerce_loop['products_layout'] == 'alternative' ) {
                            if ( $YITH_WC_Catalog_Mode->check_hide_add_cart_loop() ) {
                                remove_action( 'woocommerce_before_shop_loop_item_title', 'yit_shop_loop_add_to_cart', 20 );
                            }
                            else {
                                add_action( 'woocommerce_before_shop_loop_item_title', 'yit_shop_loop_add_to_cart', 20 );
                            }
                        }
                    }
                }
            }
        }

        /*================ Colors and Label Variations Premium ==================*/

        if( defined( 'YITH_WCCL_PREMIUM' ) && function_exists( 'YITH_WCCL_Frontend' ) ) {
            remove_filter( 'woocommerce_loop_add_to_cart_link', array( YITH_WCCL_Frontend(), 'add_select_options' ), 99, 2 );
            add_action( 'woocommerce_after_shop_loop_item_title', array( YITH_WCCL_Frontend(), 'print_select_options'  ) , 50);
        }


        /* === WPML === */

        function yit_wpml_endpoint_hack_for_after() {
            global $yit_wpml_hack_endpoint;
            $yit_wpml_hack_endpoint = WC()->query->query_vars;
            // add the options
            foreach ( $yit_wpml_hack_endpoint as $endpoint => $value ) {
                add_option( 'woocommerce_myaccount_'.$endpoint.'_endpoint', $value );
            }
        }
        add_action( 'after_setup_theme', 'yit_wpml_endpoint_hack_for_after', 11 );

        function yit_wpml_my_account_endpoint() {
            global $woocommerce_wpml, $yit_wpml_hack_endpoint;

            if ( ! isset( $woocommerce_wpml->endpoints ) ) {
                return;
            }

            $endpoints = array(
                'recent-downloads',
                'myaccount-wishlist',
            );

            $wc_vars = WC()->query->query_vars;
            
            foreach ( $endpoints as $endpoint ) {
                if ( ! isset( $yit_wpml_hack_endpoint[ $endpoint ] ) ) {
                    return;
                }

                $wc_vars_endpoint = isset( $wc_vars[ $endpoint ] ) ? $wc_vars[ $endpoint ] : $endpoint;
                WC()->query->query_vars[$endpoint] = $woocommerce_wpml->endpoints->get_endpoint_translation( $yit_wpml_hack_endpoint[$endpoint] , $wc_vars_endpoint );
            }

            unset( $yit_wpml_hack_endpoint );
        }

        add_action( 'init', 'yit_wpml_my_account_endpoint', 3 );

    }
function yith_ywraq_get_email_template($html)
{
    $raq_data['raq_content'] = YITH_Request_Quote()->get_raq_return();
    ob_start();
    if ($html) {
        wc_get_template('emails/request-quote-table.php', array('raq_data' => $raq_data));
    } else {
        wc_get_template('emails/plain/request-quote-table.php', array('raq_data' => $raq_data));
    }
    return ob_get_clean();
}
예제 #10
0
        function yit_ywraq_print_button() {

            if ( defined( 'YITH_YWRAQ_VERSION' ) ) {

                if ( yit_get_option( 'shop-layout', 'with-hover' ) == 'with-hover' ) {

                    $yith_request_quote = YITH_Request_Quote();

                    if ( method_exists( $yith_request_quote, 'add_button_shop' ) ) {
                        add_filter( 'ywraq_product_add_to_quote', 'yit_ywraq_change_button_label' );
                        ob_start();
                        $yith_request_quote->add_button_shop();
                        return ob_get_clean();
                    }
                }

            }
            return '';
        }
예제 #11
0
 */
$current_user = array();
if (is_user_logged_in()) {
    $current_user = get_user_by('id', get_current_user_id());
}
$user_name = !empty($current_user) ? $current_user->display_name : '';
$user_email = !empty($current_user) ? $current_user->user_email : '';
?>
<div class="yith-ywraq-mail-form-wrapper">
    <h3><?php 
_e('Send the request', 'ywraq');
?>
</h3>

    <form id="yith-ywraq-mail-form" name="yith-ywraq-mail-form" action="<?php 
echo esc_url(YITH_Request_Quote()->get_raq_page_url());
?>
" method="post">

            <p class="form-row form-row-wide validate-required" id="rqa_name_row">
                <label for="rqa-name" class=""><?php 
_e('Name', 'ywraq');
?>
                    <abbr class="required" title="required">*</abbr></label>
                <input type="text" class="input-text " name="rqa_name" id="rqa-name" placeholder="" value="<?php 
echo $user_name;
?>
" required>
            </p>

            <p class="form-row form-row-wide validate-required" id="rqa_email_row">