[Closed] Setting a Custom Order that every 3rd Product is a Sold Product

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.

Our next available supporter will answer your ticket in about 2.75 hours from now. Thank you for your understanding.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Related documentation:

This topic contains 11 replies, has 2 voices, and was last updated by  Luo Yang 1 week, 2 days ago. The support staff assigned to this topic is Luo Yang.

Viewing 12 posts - 1 through 12 (of 12 total)
Author
Posts
#576984

We had started another support thread however it has since been closed in regards to this.

We are attempting to add to show a Sold Product (set by CPT) every 3rd item in WordPress Archive View.

This would be a secondary filtering after menu order.

(For example we are using custom menu order for the first two pages but the second page is going to be alphabetize but we want to show a sold product every 3rd product).

Thank you so much for your help in this!

Please see http://antiquepianoshop.com/products/grand-baby-grand/ for an example of how our current system is displaying a sold product every third time.

Sincerely,

#577154

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

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

Dear John,

I assume you are using Views wordpress archive to setup the page you mentioned above, you can try the attribute "index" of shortcode [wpv-index], for example, you can edit the Views wordpress archive, inside the view loop, display the items like this:

<wpv-loop wrap="3" pad="true">
    [wpv-item index=1]
      display a normal product post
    [wpv-item index=2]
      display a normal product post 
    [wpv-item index=other]
      display a normal product post + display a sold product
 </wpv-loop>

More help:
https://wp-types.com/documentation/user-guides/views-shortcodes/#wpv-item
https://wp-types.com/documentation/user-guides/views-shortcodes/#wpv-loop

#577517

How would I go about using the index=other to display current archive product with conditional logic of the CPT?

Would this be an additional view in the index=other or would this be conditional formatting the index=other Meta HTML?

#577527

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

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

Could you elaborate the questions?
Q1) How would I go about using the index=other to display current archive product with conditional logic of the CPT?
What is the conditional logic of the CPT?
How do you setup the conditional logic?

Q2) Would this be an additional view in the index=other or would this be conditional formatting the index=other Meta HTML?
There is a misunderstanding, the codes I mentioned above work for this:
Every third item of result display a extra information for the "sold product", you can get more details in this document:
https://wp-types.com/documentation/user-guides/digging-into-view-outputs/
Views – the Loop Output

#577540

To clarify a bit:

We have 3 statuses of products (set by CPT) which are: For Sale, Sale Pending, and Sold.

We are wanting every 3rd product that is displayed in our WordPress Archive View for WooCommerce Product Categories to show a Sold Status (set by CPT) Product (that still falls in the parameters of the current archive filtering).

I believe that this type of solution with index=other would work however not sure how to go about implementing the index=other to display the results of the current archive and conditional of Sold Status CPT Products.

If it helps our old website displays the output we are trying to achieve:
antiquepianoshop.com/products/grand-baby-grand

#577575

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

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

How do you setup the "Sold" product, could you describe detail steps to duplicate same problem?
I need to test it in my localhost, thanks

#577686

The product is marked sold by a custom post field called status-of-product which has the options of being "For Sale" "Sale Pending" or "Sold"

#577783

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

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

Thanks for the details, I assume we are talking about this case:
1) create a custom post type "Product"
2) Create a custom select field "status-of-product", with options:
"For Sale" "Sale Pending" and "Sold"
3) You are going to display the "Product" posts in the archive page of post type "Product", as below:
Normal product 1, Normal product 2, Normal product 3, Sold product A
Normal product 4, Normal product 5, Normal product 6, Sold product B
...

If it is, there isn't such a built-in feature within Views plugin, Views is using wordpress class WP_Query to query the posts of databases, there isn't such an option to achieve what you want, see wordpress document:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
There isn't such a feature to sort the results as what you want.

If you agree, we can take it as a feature request, currently you can check out our Toolset certified consultants for it:
https://wp-types.com/toolset-support-policy/

#577791

The Products themselves are WooCommerce Products with an added Custom Post Type that is status-of-product.

Our instances we are looking to achieve would look like this

For Sale Item 1, For Sale Item 2, Sold Item 1, For Sale Item 3... so forth and so on.

Would using the index=other with the instance of

$args = array(
'post_type' => 'my_custom_post_type',
'meta_key' => 'age',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'age',
'value' => array( 3, 4 ),
'compare' => 'IN',
),
),
);
$query = new WP_Query( $args );

Set to post type product, meta_key = CPT work to display every third instance as sold?

#577808

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

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

There is a misunderstanding, the shortcode [wpv-item index=x] can locate this x item of result, but it can not change the x item into a sold product, the order of results is defined be the wordpress query, since WP_Query does not support what you are going to achieve, so there isn't such a built-in feature. see my above post:
https://wp-types.com/forums/topic/setting-a-custom-order-that-every-3rd-product-is-a-sold-product/#post-577783

#578034

Okay skipping to WP_Query...

Would I not be able to use the query to default sorting to menu order and then add an array for custom post types, wouldn't using an array that showcases the custom post type value of Sold every nth time work?

#578048

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

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

As I mentioned above, there isn't such a feature within Views plugin.
It needs custom codes, according to our support policy, we do not provide custom codes support, I suggest you check out our Toolset certified consultants for it:
https://wp-types.com/consultant/

Here is a workaround, but it is not exactly what you are going to achieve:
1) You can create another view to display only one sold product, orderby random
2) after the shortcode [wpv-item index=x], display above view, it will be able to display a random sold product post.

Viewing 12 posts - 1 through 12 (of 12 total)

The topic ‘[Closed] Setting a Custom Order that every 3rd Product is a Sold Product’ is closed to new replies.