YITH Request a Quote for WooCommerce Shortcodes

Below, you’ll find a detailed guide on how to add the YITH Request a Quote for WooCommerce Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the YITH Request a Quote for WooCommerce Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the YITH Request a Quote for WooCommerce Plugin and the shortcodes it provides:

Plugin Icon
YITH Request a Quote for WooCommerce

"YITH Request a Quote for WooCommerce is a unique plugin that allows customers to request price quotations directly from your WooCommerce store, enhancing customer interaction and sales."

★★★✩✩ (56) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [yith_ywraq_request_quote]
  • [yith_ywraq_button_quote]

YITH Request a Quote for WooCommerce [yith_ywraq_request_quote] Shortcode

The YITH WooCommerce Request a Quote shortcode is a powerful tool that enables customers to request a quote for products. This shortcode generates a list of products added by users for a quote request. It retrieves the quote request data, passes it into an array, and then renders the ‘request-quote.php’ template. This allows users to view their quote requests, providing a seamless shopping experience.

Shortcode: [yith_ywraq_request_quote]

Examples and Usage

Basic example – Utilizes the default ‘yith_ywraq_request_quote’ shortcode to display the Request a Quote list on your website.

[yith_ywraq_request_quote /]

PHP Function Code

In case you have difficulties debugging what causing issues with [yith_ywraq_request_quote] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'yith_ywraq_request_quote', array( $this, 'request_quote_list' ) );

Shortcode PHP function:

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();
		wc_get_template( 'request-quote.php', $args, '', YITH_YWRAQ_TEMPLATE_PATH );
		return ob_get_clean();
	}

Code file location:

yith-woocommerce-request-a-quote/yith-woocommerce-request-a-quote/includes/class.yith-ywraq-shortcodes.php

YITH Request a Quote for WooCommerce [yith_ywraq_button_quote] Shortcode

The YITH WooCommerce Request a Quote shortcode allows you to add a customizable “Add to Quote” button to your product pages. This button, when clicked, adds the product to a quote request list. The shortcode’s attributes allow you to specify the product, label text, button style, color scheme, and whether to display an icon. The colors for the button and its hover state can be customized. The function ‘yith_ywraq_render_button’ is called to generate the button, with the output being returned after being buffered.

Shortcode: [yith_ywraq_button_quote]

Parameters

Here is a list of all possible yith_ywraq_button_quote shortcode parameters and attributes:

  • product – Specifies the product to be quoted
  • label – Sets the text displayed on the quote button
  • style – Determines whether a button or link is displayed
  • colors – Defines the color scheme of the quote button
  • icon – Allows an icon to be added to the quote button
  • bg_color – Sets the background color of the button
  • bg_color_hover – Determines the hover background color of the button
  • color – Sets the text color of the button
  • color_hover – Defines the hover text color of the button

Examples and Usage

Basic example – A simple usage of the shortcode to display the ‘Add to quote’ button with default label and style.

[yith_ywraq_button_quote /]

Advanced examples

Using the shortcode to display the ‘Add to quote’ button with a custom label and button style.

[yith_ywraq_button_quote label="Request a Quote" style="button" /]

Using the shortcode to display the ‘Add to quote’ button with custom colors. The button will have a blue background color, white text color, darker blue background color on hover, and white text color on hover.

[yith_ywraq_button_quote colors="bg_color='#0000FF', color='#FFFFFF', bg_color_hover='#00008B', color_hover='#FFFFFF'" /]

Using the shortcode to display the ‘Add to quote’ button for a specific product. The product ID is 123 in this example.

[yith_ywraq_button_quote product="123" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [yith_ywraq_button_quote] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'yith_ywraq_button_quote', array( $this, 'button_quote' ) );

Shortcode PHP function:

function button_quote( $atts, $content = null ) {

		if ( ! wp_script_is( 'enqueued', 'yith_ywraq_frontend' ) ) {
			wp_enqueue_style( 'yith_ywraq_frontend' );
		}
		$args = shortcode_atts(
			array(
				'product' => false,
				'label'   => get_option( 'ywraq_show_btn_link_text', __( 'Add to quote', 'yith-woocommerce-request-a-quote' ) ),
				'style'   => ( get_option( 'ywraq_show_btn_link' ) === 'button' ) ? 'button' : 'ywraq-link',
				'colors'  => get_option(
					'ywraq_add_to_quote_button_color',
					array(
						'bg_color'       => '#0066b4',
						'bg_color_hover' => '#044a80',
						'color'          => '#ffffff',
						'color_hover'    => '#ffffff',
					)
				),
				'icon'    => 0,

			),
			$atts
		);

		if ( 'button' === $args['style'] ) {
			if ( isset( $atts['bg_color'] ) ) {
				$args['colors']['bg_color'] = $atts['bg_color'];
			}
			if ( isset( $atts['bg_color_hover'] ) ) {
				$args['colors']['bg_color_hover'] = $atts['bg_color_hover'];
			}
			if ( isset( $atts['color'] ) ) {
				$args['colors']['color'] = $atts['color'];
			}

			if ( isset( $atts['color_hover'] ) ) {
				$args['colors']['color_hover'] = $atts['color_hover'];
			}
		}

		ob_start();

		yith_ywraq_render_button( $args['product'], $args );

		return ob_get_clean();
	}

Code file location:

yith-woocommerce-request-a-quote/yith-woocommerce-request-a-quote/includes/class.yith-ywraq-shortcodes.php

Conclusion

Now that you’ve learned how to embed the YITH Request a Quote for WooCommerce Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *