Skip Navigation

[Resolved] Using custom shortcode to update number of product results on page

This thread is resolved. Here is a description of the problem and solution.

Problem:

Custom shortcode does not work in View's outputs.

Solution:

he Views AJAX feature works in two blocks:
a) [wpv-layout-start] ... [wpv-layout-end]
b) [wpv-filter-start] ... [wpv-filter-end]

In section "Loop Editor" of above post view, you can put the custom shortcodes in section "Loop Editor" to just below the shortcode [wpv-layout-start], like this:

https://toolset.com/forums/topic/using-custom-shortcode-to-update-number-of-product-results-on-page/#post-1235412

Relevant Documentation:

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by robina-2 5 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1235147
front-end-view.jpg
custom-shortcode.png
view.png
ajax-settings.png

We have a View that is displaying WooCommerce Products. We have created a custom shortcode in order to do a better job with showing the number of products within each page of the pagination of products in the view. See ‘front-end-view.png’.

We are using the AJAX method for both the Pagination and Filters, however, our own custom shortcode does not work in conjunction with your AJAX requests, so when we are using the pagination to move through the pages, and using the search filter checkboxes, this custom shortcode is not updating the text (this is the text that shows “1-12” in the attached ‘front-end-view.png’).

Is there any way that you know of that we can hook into your AJAX request somehow in order to dynamically update our shortcode?

Here is access to the page from the screenshot:
hidden link

Any guidance at all would be much appreciated, thank you!

#1235409

Hello,

Thanks for the details, I have edited your post to remove the credentials, and I am checking it in your website, will update here if there is anything found

#1235412

Here are what I found, two issues:
1) It seems you are going to update the view's result without submit button, so I have done below modification in your website:
Edit the post view "Products - Harle Test", in section "Custom Search Settings", change the option from:
AJAX results update when visitors click on the search button
To:
AJAX results update when visitors change any filter values

2) The Views AJAX feature works in two blocks:
a) [wpv-layout-start] ... [wpv-layout-end]
b) [wpv-filter-start] ... [wpv-filter-end]

In section "Loop Editor" of above post view, I have copied your shortcodes in section "Loop Editor" to just below the shortcode [wpv-layout-start], like this:

...
[wpv-layout-start]
  Showing [pagination_number_12] of [wpv-found-count] results
...

Test it in front-end, it works fine:
hidden link

Please test again, check if it is fixed. thanks

#1237199

My issue is resolved now. Thank you!