Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wpsc_single_template query issue #844

Closed
misulicus opened this issue Jan 17, 2014 · 3 comments

Comments

Projects
None yet
4 participants
@misulicus
Copy link
Member

commented Jan 17, 2014

posting issue reported by customer:

I had created a product with several variants for different bundle sizes: single, pack of 20, and pack of 50.

Unfortunately, I found the way variants are handled in WP eCommerce to be completely inadequate for my needs, so I scrapped the variants and set up separate products instead. This is where things got wonky...

One of the products I called "The Comfort Circle - Bookmark Reference (Single)", which resulted in a slug of "the-comfort-circle-bookmark-reference-single". As it happened, the variants created database records that had the same slug as the new page. Also, when I trashed the page and created a new one, it ended up with the same slug as the previous.

Here's where WPEC broke:
In wpsc_single_template() there is a check that (effectively) ensures $wp_query->post_count === 1 ... and I noticed it was showing 3. As it turns out, the query being tested was not excluding items where post_status = "trash". As a result, each variant and deleted product that had the same slug name were causing post_count to exceed 1.

Once I emptied the trash, the templates started displaying correctly again. This function needs to be rewritten so that when post_count > 1 the template system does not break.

@JustinSainton JustinSainton added this to the 3.9.0 milestone Mar 4, 2014

@JustinSainton

This comment has been minimized.

Copy link
Member

commented Mar 4, 2014

An edge case, for sure, but one worth addressing. Not going to touch this for 3.8.14, given how late in the cycle it is.

@JustinSainton

This comment has been minimized.

Copy link
Member

commented Oct 15, 2014

Needs more testing here, but I'm honestly unsure as to why we couldn't use is_singular( 'wpsc-product' ) in place of if ( !is_archive() && $wp_query->post_count > 0 && 'wpsc-product' == $wp_query->post->post_type && $wp_query->post_count <= 1 ) {

@1bigidea

This comment has been minimized.

Copy link
Contributor

commented Jun 17, 2015

I tried to recreate this issue. But WordPress appears to correctly deliver a single post regardless of how many posts have the same slug to this function. That said, the query that is executed within this function could return the wrong post since it doesn't test for post_status. This PR addresses that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.