• Resolved Diego Versiani

    (@diegoversiani)


    Hi there,

    I’m the developer of Fluid Checkout, a plugin that replaces the WooCommerce classic and blocks checkout form with a better user experience.

    Some of our customers are having issues when using Fluid Checkout and the Advanced Coupons plugins when they add the checkout form to the page content using the new Block-based Checkout form.

    The layout of the Advanced Coupon section look broken and trying to apply discounts do not work properly.

    I checked the code on your plugin and found out that the function is_current_page_using_cart_checkout_block checks whether the checkout page is using the block-based or shortcode-based checkout form and treat these checkout experiences differently.

    /**
    * Check if the current page is using cart or checkout block.
    *
    * @since 4.5.9
    * @access public
    *
    * @return bool Returns true if the cart page is using blocks, false otherwise.
    */
    public function is_current_page_using_cart_checkout_block() {
    global $post;

    // Bail early if post is not set.
    if ( ! $post instanceof \WP_Post ) {
    return false;
    }

    // Check if the content is using regular cart and checkout block shortcode.
    if ( has_shortcode( $post->post_content, 'woocommerce_cart' ) || has_shortcode( $post->post_content, 'woocommerce_checkout' ) ) {
    return false;
    }

    // check if page using cart or checkout block.
    if ( has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' ) ) {
    return true;
    }

    return false;
    }

    Fluid Checkout dynamically replaces the original WooCommerce Checkout block with the Classic Shortcode-based form, that is, without actually changing the content of the page on the database. Because of that, your function will always return that the Block-based checkout form is being used, even when that is not the case.

    1. Would it be possible for you to add a filter to this function so that Fluid Checkout can correct the value returned by this function, setting it as using the Shortcode-based checkout form instead?

    Ideally this filter would be placed at the top of the of the function to “hijack” the value returned (see below). Otherwise, if could also be placed at the bottom in which case more profound changes would be required to the way this function works.

    Here is an example of how the filter could be implemented:

    /**
    * Check if the current page is using cart or checkout block.
    *
    * @since 4.5.9
    * @access public
    *
    * @return bool Returns true if the cart page is using blocks, false otherwise.
    */
    public function is_current_page_using_cart_checkout_block() {
    global $post;

    // Allow developers to hijack the returning value
    $value_from_filter = apply_filters( 'acfw_filter_is_current_page_using_cart_checkout_block', null );
    if ( null !== $value_from_filter && is_bool( $value_from_filter ) ) {
    return $value_from_filter;
    }

    // Bail early if post is not set.
    if ( ! $post instanceof \WP_Post ) {
    return false;
    }

    // Check if the content is using regular cart and checkout block shortcode.
    if ( has_shortcode( $post->post_content, 'woocommerce_cart' ) || has_shortcode( $post->post_content, 'woocommerce_checkout' ) ) {
    return false;
    }

    // check if page using cart or checkout block.
    if ( has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' ) ) {
    return true;
    }

    return false;
    }

    Best,
    Diego.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Fauzan Azizie

    (@fauzanade)

    Hi @diegoversiani,

    Thanks for bringing this up to us. I’ve escalated this to our dev team to add in our next update.

    Thread Starter Diego Versiani

    (@diegoversiani)

    Hi @fauzanade,

    Thanks.

    1. Could you let me know here once a new version has been released with this fix?

    Best,
    Diego.

    Thread Starter Diego Versiani

    (@diegoversiani)

    Hi @fauzanade,

    A new version of Advanced Coupons has been released today, but I don’t see this change incorporated yet.

    1. Could you double check whether this has been incorporated, and if so, what is the filter hook name that we should be using?
    2. Otherwise, could you check again with the development team when this change would be incorporated?

    Best,
    Diego.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.