Cartflows Shortcodes

Below, you’ll find a detailed guide on how to add the Cartflows 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 Cartflows Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Cartflows Plugin and the shortcodes it provides:

Plugin Icon
WooCommerce Checkout & Funnel Builder by CartFlows – Create High Converting Stores For WooCommerce

"WooCommerce Checkout & Funnel Builder by CartFlows is a powerful plugin that helps you create high-converting, optimized online stores for WooCommerce. It simplifies the checkout process and enhances your sales funnel for maximum profitability."

★★★★☆ (318) Active Installs: 200000+ Tested with: 6.3.2 PHP Version: 7.2
Included Shortcodes:
  • [cartflows_checkout]
  • [cartflows_next_step_link]
  • [cartflows_navigation]
  • [cartflows_optin]
  • [cartflows_order_details]
  • [cartflows_product_title]
  • [cartflows_product_add_to_cart]

Cartflows [cartflows_checkout] Shortcode

The CartFlows Checkout shortcode is a functional tool that generates a checkout form. It checks if WooCommerce functions exist and reloads the page if they don’t. It retrieves the checkout ID from the attributes and displays an error message if the ID is not found. The shortcode then initiates the checkout form layout based on the checkout ID. Shortcode: [cartflows_checkout id=”your_checkout_id”] It uses a default template for the checkout layout but allows for custom templates if they exist. The output is the final checkout form.

Shortcode: [cartflows_checkout]

Parameters

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

  • id – It’s the unique identifier of the checkout page.

Examples and Usage

Basic example – Displaying a checkout form by referencing the checkout ID

[cartflows_checkout id=1 /]

Advanced examples

Using the shortcode to display a checkout form by referencing the checkout ID and reloading the page if WooCommerce functions do not exist.

[cartflows_checkout id=1 /]

Using the shortcode to display a checkout form by referencing the checkout ID. If the checkout ID is not found, it displays an error message and a link to a documentation article.

[cartflows_checkout id=0 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'cartflows_checkout', array( $this, 'checkout_shortcode_markup' ) );

Shortcode PHP function:

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'] );

		$show_checkout_demo = false;

		if ( is_admin() ) {

			$show_checkout_demo = apply_filters( 'cartflows_show_demo_checkout', false );

			if ( $show_checkout_demo && 0 === $checkout_id && isset( $_POST['id'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing
				$checkout_id = intval( $_POST['id'] ); //phpcs:ignore WordPress.Security.NonceVerification.Missing
			}
		}

		if ( empty( $checkout_id ) ) {

			if ( ! _is_wcf_checkout_type() && false === $show_checkout_demo ) {

				$error_html  = '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
				$error_html .= '<p>' . sprintf(
					/* translators: %1$1s, %2$2s Link to article */
					__( 'It seems that this is not the CartFlows Checkout page where you have added this shortcode. Please refer to this %1$1sarticle%2$2s to know more.', 'cartflows' ),
					'<a href="https://cartflows.com/docs/resolve-checkout-id-not-found-error/?utm_source=dashboard&utm_medium=free-cartflows&utm_campaign=docs" target="_blank">',
					'</a>'
				) . '</p>';

				return $error_html;
			}

			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;
	}

Code file location:

cartflows/cartflows/modules/checkout/classes/class-cartflows-checkout-markup.php

Cartflows [cartflows_next_step_link] Shortcode

The CartFlows Next Step Link shortcode is a functional tool that generates the URL for the next step in a flow. This shortcode checks if the current post is a CartFlows step. If it is, it retrieves the flow ID and checks if there are any subsequent steps in the flow. If a next step exists, it fetches the URL of that step and outputs it. This allows for seamless navigation through the flow.

Shortcode: [cartflows_next_step_link]

Examples and Usage

Basic example – The CartFlows Next Step Link shortcode is utilized to generate a link to the subsequent step in a CartFlows sequence. The shortcode does not require any attributes or parameters.

[cartflows_next_step_link /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'cartflows_next_step_link', array( $this, 'next_step_link' ) );

Shortcode PHP function:

function next_step_link( $atts ) {

		global $post;

		$output = '#';

		if ( $post && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {

			$navigation = false;

			$step_id = intval( $post->ID );
			$flow_id = get_post_meta( $step_id, 'wcf-flow-id', true );

			if ( ! $flow_id ) {
				return $output;
			}

			$steps = get_post_meta( $flow_id, 'wcf-steps', true );

			if ( ! is_array( $steps ) || ( is_array( $steps ) && empty( $steps ) ) ) {
				return $output;
			}

			foreach ( $steps as $i => $step ) {

				if ( intval( $step['id'] ) === $step_id ) {

					$next_i = $i + 1;

					if ( isset( $steps[ $next_i ] ) ) {
						$navigation = $steps[ $next_i ];
					}

					break;
				}
			}

			if ( $navigation && is_array( $navigation ) ) {

				$output = get_permalink( $navigation['id'] );
			}
		}

		return $output;
	}

Code file location:

cartflows/cartflows/modules/flow/classes/class-cartflows-flow-shortcodes.php

Cartflows [cartflows_navigation] Shortcode

The CartFlows Navigation shortcode is a functional tool that aids in site navigation. It dynamically generates links to guide users through various steps within a flow. The shortcode allows customization of the label and icon, and even the icon’s position. It checks the current post type and if it matches with CartFlows step post type, it fetches the next step in the flow and generates a link to it. This shortcode is beneficial for creating intuitive and user-friendly navigation in your WordPress site.

Shortcode: [cartflows_navigation]

Parameters

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

  • label – sets the text displayed on the navigation button
  • icon – adds a custom icon to the navigation button
  • icon_position – determines whether the icon appears before or after the label

Examples and Usage

Basic example – A simple usage of the ‘cartflows_navigation’ shortcode without any parameters. This will display the navigation link to the next step in the flow, with the default label ‘Next Step’.

[cartflows_navigation /]

Advanced examples

Adding a custom label to the navigation link. This will replace the default ‘Next Step’ label with the provided custom label.

[cartflows_navigation label="Proceed to Next Step" /]

Adding an icon to the navigation link. The ‘icon’ parameter can be used to add a custom icon before or after the label. The ‘icon_position’ parameter determines where the icon will be placed relative to the label. ‘before’ places the icon before the label, and ‘after’ places it after the label.

[cartflows_navigation label="Proceed to Next Step" icon="fa-arrow-right" icon_position="after" /]

In the above example, ‘fa-arrow-right’ is a Font Awesome icon class. If you’re using a different icon library, replace ‘fa-arrow-right’ with the appropriate class from your library.

PHP Function Code

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

Shortcode line:

add_shortcode( 'cartflows_navigation', array( $this, 'navigation_shortcode' ) );

Shortcode PHP function:

function navigation_shortcode( $atts ) {
		$atts = shortcode_atts(
			array(
				'label'         => '',
				'icon'          => '',
				'icon_position' => '',
			),
			$atts
		);

		global $post;

		$output = '';

		if ( $post && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {

			$navigation = false;

			$step_id = intval( $post->ID );
			$flow_id = get_post_meta( $step_id, 'wcf-flow-id', true );

			if ( ! $flow_id ) {
				return $output;
			}

			$steps = get_post_meta( $flow_id, 'wcf-steps', true );

			if ( ! is_array( $steps ) || ( is_array( $steps ) && empty( $steps ) ) ) {
				return $output;
			}

			foreach ( $steps as $i => $step ) {

				if ( intval( $step['id'] ) === $step_id ) {

					$next_i = $i + 1;

					if ( isset( $steps[ $next_i ] ) ) {
						$navigation = $steps[ $next_i ];
					}

					break;
				}
			}

			if ( $navigation && is_array( $navigation ) ) {

				$label  = ( '' != $atts['label'] ) ? $atts['label'] : __( 'Next Step', 'cartflows' );
				$before = '';
				$after  = '';

				if ( '' != $atts['icon'] ) {
					if ( '' != $atts['icon_position'] ) {
						if ( 'before' == $atts['icon_position'] ) {
							$before = '<span class="wcf-nextstep-icon wcf-nextstep-icon-before"><i class="' . $atts['icon'] . '" aria-hidden="true"></i></span>';
						} else {
							$after = '<span class="wcf-nextstep-icon wcf-nextstep-icon-after"><i class="' . $atts['icon'] . '" aria-hidden="true"></i></span>';
						}
					}
				}

				$output = '<div><a target="_self" href="' . get_permalink( $navigation['id'] ) . '">' . $before . $label . $after . '</a></div>';
			}
		}

		return $output;
	}

Code file location:

cartflows/cartflows/modules/flow/classes/class-cartflows-flow-shortcodes.php

Cartflows [cartflows_optin] Shortcode

The ‘cartflows_optin’ shortcode is a powerful tool that enables the display of WooCommerce optin forms. It checks for WooCommerce functions and if they don’t exist, it provides a reload option. The shortcode also allows you to specify an ‘id’ attribute for the optin form. It includes a feature to preview the optin form in the admin panel. If the shortcode is not placed on an Optin step-type, it will return an error message. The output of the shortcode is the optin form, which is generated from the ‘optin-template-simple.php’ file. This shortcode is an excellent tool for enhancing your WooCommerce site’s user experience.

Shortcode: [cartflows_optin]

Parameters

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

  • id – Identifies a specific optin form to display

Examples and Usage

Basic example – The basic usage of the ‘cartflows_optin’ shortcode only requires the ‘id’ attribute. This attribute should hold the value of the ID of the opt-in form you want to display.

[cartflows_optin id=1 /]

Advanced examples

In a more advanced scenario, you might want to use the ‘cartflows_optin’ shortcode within a conditional statement. For example, you could check if the user is an administrator before displaying the opt-in form. This can be achieved by using the ‘is_admin’ attribute. Please note that this attribute is not officially supported and requires custom PHP code to work.


<?php
if(current_user_can('administrator')) {
    echo do_shortcode('[cartflows_optin id=1 /]');
}
?>

Another advanced usage could be to display a different opt-in form based on the post ID. This can be achieved by using the global ‘$post’ variable within the shortcode. Again, this requires custom PHP code.


<?php
global $post;
echo do_shortcode('[cartflows_optin id=' . $post->ID . ' /]');
?>

Please note that these advanced examples require a basic understanding of PHP and WordPress shortcodes. If you are not comfortable with coding, it is recommended to stick with the basic usage of the ‘cartflows_optin’ shortcode.

PHP Function Code

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

Shortcode line:

add_shortcode( 'cartflows_optin', array( $this, 'optin_shortcode_markup' ) );

Shortcode PHP function:

function optin_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
		);

		$optin_id = intval( $atts['id'] );

		$show_optin_preview = false;

		if ( is_admin() ) {

			$show_optin_preview = apply_filters( 'cartflows_show_demo_optin_form', false );

			if ( $show_optin_preview && 0 === $optin_id ) {

				if ( isset( $_POST['id'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing
					$optin_id = intval( $_POST['id'] ); //phpcs:ignore WordPress.Security.NonceVerification.Missing
				}
			}
		}

		if ( empty( $optin_id ) && ! is_admin() ) {

			if ( ! _is_wcf_optin_type() && ! $show_optin_preview ) {

				return '<h4>' . __( 'Please place shortcode on Optin step-type only.', 'cartflows' ) . '</h4>';
			}

			global $post;
			$optin_id = intval( $post->ID );

		}

		$output = '';

		ob_start();

		do_action( 'cartflows_optin_form_before', $optin_id );

		$optin_layout = 'default';

		$template_default = CARTFLOWS_OPTIN_DIR . 'templates/optin-template-simple.php';

		include $template_default;

		$output .= ob_get_clean();

		return $output;
	}

Code file location:

cartflows/cartflows/modules/optin/classes/class-cartflows-optin-markup.php

Cartflows [cartflows_order_details] Shortcode

The CartFlows Order Details shortcode is a powerful tool that displays the details of a customer’s order. It checks for the existence of the WooCommerce functions and retrieves the latest order details if in test mode. If no order is found, it returns an error message.

Shortcode: [cartflows_order_details]

Examples and Usage

Basic example – The following shortcode displays the details of a specific order when the order ID is provided.

[cartflows_order_details id="123" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'cartflows_order_details', array( $this, 'cartflows_order_details_shortcode_markup' ) );

Shortcode PHP function:

function cartflows_order_details_shortcode_markup( $atts ) {
		$output = '';

		$show_demo_order = false;

		// Allow to execute the order detais shortcode for modules.
		if ( current_user_can( 'manage_options' ) ) {
			$show_demo_order = apply_filters( 'cartflows_show_demo_order_details', false );
		}

		if ( _is_wcf_thankyou_type() || $show_demo_order ) {
			/* Remove order item link */
			add_filter( 'woocommerce_order_item_permalink', '__return_false' );

			/* Change order text */
			add_filter( 'woocommerce_thankyou_order_received_text', array( $this, 'custom_tq_text' ), 10, 2 );

			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;
			}

			$order = false;

			$id_param  = 'wcf-order';
			$key_param = 'wcf-key';
			//phpcs:disable WordPress.Security.NonceVerification.Recommended
			if ( isset( $_GET['wcf-opt-order'] ) ) {
				$id_param  = 'wcf-opt-order';
				$key_param = 'wcf-opt-key';
			}

			if ( ! isset( $_GET[ $id_param ] ) && ( wcf()->flow->is_flow_testmode() || $show_demo_order ) ) {
				$args = array(
					'limit'     => 1,
					'order'     => 'DESC',
					'post_type' => 'shop_order',
					'status'    => array( 'completed', 'processing' ),
				);

				$latest_order = wc_get_orders( $args );

				$order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0;

				if ( $order_id > 0 ) {
					$order = wc_get_order( $order_id );

					if ( ! $order ) {
						$order = false;
					}
				} else {
					return '<p class="woocommerce-notice">' . __( 'No completed or processing order found to show the order details form demo.', 'cartflows' ) . '</p>';
				}
			} else {
				if ( ! isset( $_GET[ $id_param ] ) ) {
					return '<p class="woocommerce-notice">' . __( 'Order not found. You cannot access this page directly.', 'cartflows' ) . '</p>';
				}

				// Get the order.
				$order_id  = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET[ $id_param ] ) ? 0 : intval( $_GET[ $id_param ] ) );
				$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET[ $key_param ] ) ? '' : wc_clean( wp_unslash( $_GET[ $key_param ] ) ) );
				//phpcs:enable WordPress.Security.NonceVerification.Recommended
				if ( $order_id > 0 ) {
					$order = wc_get_order( $order_id );

					if ( ! $order || $order->get_order_key() !== $order_key ) {
						$order = false;
					}
				}
			}

			// Empty awaiting payment session.
			unset( WC()->session->order_awaiting_payment );

			if ( null !== WC()->session ) {
				if ( ! isset( WC()->cart ) || '' === WC()->cart ) {
					WC()->cart = new WC_Cart();
				}

				if ( ! WC()->cart->is_empty() ) {
					// wc_empty_cart();
					// Empty current cart.
					WC()->cart->empty_cart( true );

					wc_clear_notices();
				}

				wc_print_notices();
			}

			do_action( 'cartflows_thankyou_details_before', $order );

			ob_start();
			echo "<div class='wcf-thankyou-wrap' id='wcf-thankyou-wrap'>";
			wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
			echo '</div>';
			$output = ob_get_clean();
		}

		return $output;
	}

Code file location:

cartflows/cartflows/modules/thankyou/classes/class-cartflows-thankyou-markup.php

Cartflows [cartflows_product_title] Shortcode

The CartFlows Product Title shortcode is a useful tool in WordPress. It fetches and displays the title of a specific product based on its ID. The shortcode requires an ‘id’ parameter which corresponds to the product’s ID. If the ‘id’ is not provided or invalid, it returns an empty string. Otherwise, it calls the ‘get_product_obj’ function to retrieve the product object and then returns the product’s title.

Shortcode: [cartflows_product_title]

Parameters

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

  • id – It is the unique identifier of a specific product

Examples and Usage

Basic example – A simple usage of the ‘cartflows_product_title’ shortcode to display the title of a product with the ID 123.

[cartflows_product_title id=123 /]

Advanced examples

Using the ‘cartflows_product_title’ shortcode to display the title of a product with the ID 456. If the product with ID 456 doesn’t exist, the shortcode returns an empty string.

[cartflows_product_title id=456 /]

Utilizing the ‘cartflows_product_title’ shortcode to display the title of a product with the ID 789. If the product with ID 789 doesn’t exist, the shortcode returns an empty string.

[cartflows_product_title id=789 /]

Note: In all the examples above, replace the number after ‘id=’ with the ID of the product you want to display the title of. The ‘cartflows_product_title’ shortcode is a powerful tool for dynamically displaying product titles in your WordPress site.

PHP Function Code

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

Shortcode line:

add_shortcode( 'cartflows_product_title', array( $this, 'product_title' ) );

Shortcode PHP function:

function product_title( $atts ) {

		if ( empty( $atts['id'] ) ) {
			return '';
		}

		$product_id = intval( $atts['id'] );
		$product    = $this->get_product_obj( $product_id );

		if ( ! $product ) {
			return '';
		}

		return $product->get_title();
	}

Code file location:

cartflows/cartflows/modules/woo-dynamic-flow/classes/class-cartflows-wd-flow-shortcodes.php

Cartflows [cartflows_product_add_to_cart] Shortcode

The CartFlows plugin shortcode, ‘cartflows_product_add_to_cart’, adds a specific product to the cart. It accepts parameters like ‘id’, ‘status’, ‘text’, and ‘show_title’. . The ‘id’ parameter identifies the product. ‘Status’ sets the post status. ‘Text’ alters the add-to-cart button text, while ‘show_title’ toggles product title visibility.

Shortcode: [cartflows_product_add_to_cart]

Parameters

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

  • id – Unique identifier for the selected product.
  • status – Determines the post status of the product, default is ‘publish’.
  • text – Customizes the add-to-cart button text.
  • show_title – Controls whether the product title is displayed or not.

Examples and Usage

Basic example – An example of a basic usage of the shortcode, which adds a product to the cart by referencing the product’s ID.

[cartflows_product_add_to_cart id=10 /]

Advanced examples

Here, we use the shortcode to add a product to the cart, with the product ID and status parameters. The status parameter is optional and defaults to ‘publish’ if not specified.

[cartflows_product_add_to_cart id=10 status='draft' /]

Another advanced usage of the shortcode includes specifying the ‘text’ attribute, which changes the add to cart button text, and the ‘show_title’ attribute, which controls whether the product title is displayed.

[cartflows_product_add_to_cart id=10 text='Buy Now' show_title=false /]

This shortcode demonstrates the maximum usage of parameters, including ‘id’, ‘status’, ‘text’, and ‘show_title’. It adds a product to the cart, changes the add to cart button text, sets the product status, and controls the display of the product title.

[cartflows_product_add_to_cart id=10 status='draft' text='Purchase Now' show_title=false /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'cartflows_product_add_to_cart', array( $this, 'add_to_cart' ) );

Shortcode PHP function:

function add_to_cart( $atts ) {

		if ( empty( $atts['id'] ) ) {
			return '';
		}

		$args = array(
			'posts_per_page'      => 1,
			'post_type'           => 'product',
			'post_status'         => ( ! empty( $atts['status'] ) ) ? $atts['status'] : 'publish',
			'ignore_sticky_posts' => 1,
			'no_found_rows'       => 1,
		);

		if ( isset( $atts['id'] ) ) {
			$args['p'] = absint( $atts['id'] );
		}

		// Update the add to cart button text.
		if ( isset( $atts['text'] ) && ! empty( $atts['text'] ) ) {

			self::$add_to_cart_text = sanitize_text_field( $atts['text'] );

			add_filter( 'woocommerce_product_single_add_to_cart_text', array( $this, 'replace_add_to_cart_text' ), 40, 2 );
		}

		// Don't render titles if desired.
		if ( isset( $atts['show_title'] ) && ! $atts['show_title'] ) {
			remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
		}

		// Change form action to avoid redirect.
		add_filter( 'woocommerce_add_to_cart_form_action', '__return_empty_string' );

		$single_product = new WP_Query( $args );

		// For "is_single" to always make load comments_template() for reviews.
		$single_product->is_single = true;

		ob_start();

		global $product;
		global $wp_query;

		// Backup query object so following loops think this is a product page.
		$previous_wp_query = $wp_query;
		$wp_query          = $single_product; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited

		wp_enqueue_script( 'wc-single-product' );

		while ( $single_product->have_posts() ) {

			$single_product->the_post();

			woocommerce_template_single_add_to_cart();

			/*
			?>
			<div class="single-product" data-product-page-preselected-id="<?php echo esc_attr( $preselected_id ); ?>">
				<?php wc_get_template_part( 'content', 'single-product' ); ?>
			</div>
			<?php
			*/
		}

		// Restore $previous_wp_query and reset post data.
		$wp_query = $previous_wp_query; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited

		wp_reset_postdata();

		// Remove text change action.
		if ( isset( $atts['text'] ) && ! empty( $atts['text'] ) ) {

			self::$add_to_cart_text = '';

			remove_filter( 'woocommerce_product_single_add_to_cart_text', array( $this, 'replace_add_to_cart_text' ), 40, 2 );
		}

		// Re-enable titles if they were removed.
		if ( isset( $atts['show_title'] ) && ! $atts['show_title'] ) {
			add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
		}

		remove_filter( 'woocommerce_add_to_cart_form_action', '__return_empty_string' );

		return '<div class="woocommerce wcf-product-atc">' . ob_get_clean() . '</div>';
	}

Code file location:

cartflows/cartflows/modules/woo-dynamic-flow/classes/class-cartflows-wd-flow-shortcodes.php

Conclusion

Now that you’ve learned how to embed the Cartflows 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 *