WordPress.org

Ready to get started?Download WordPress

Forums

WP e-Commerce Cross Sales (Also Bought)
Variation Product IDs Not Being Stored in wpsc_als (2 posts)

  1. bnance
    Member
    Posted 2 years ago #

    My products have variations such as size, color, etc. Using v 0.1 of WP e-Commerce Cross Sales (Also Bought) and WPSC 3.8.6.

    When a product variation is purchased, the variation product_id is stored in wpsc_also_bought. However, when the single product page is viewed, wpsc_cross_sales( wpsc_the_product_id() ) looks for the base product_id. Since the base product_id was not stored in the table, not "also bought" products show up on the Single Product page.

    Does anyone have an idea how to resolve this issue? It would see that only the base product_id should be stored in wpsc_also_bought.

    Thanks!

    http://wordpress.org/extend/plugins/wp-e-commerce-cross-sales/

  2. Simplii Web
    Member
    Posted 1 year ago #

    I was able to fix this on my own. here is how to do it.

    WP eCommerce Version: 3.8.4

    find file wp-ecommerce/wpsc-include/display.functions.php

    around line 80 or serch for "$also_bought = $wpdb->get_results"

    and replace the following:

    $also_bought = $wpdb->get_results( "SELECT" . $wpdb->posts . ".* FROM" . $wpdb->posts . "WHERE" . $wpdb->posts . ".idIN (SELECT" . $wpdb->posts . ".post_parentFROM" . WPSC_TABLE_ALSO_BOUGHT . "," . $wpdb->posts . "WHEREselected_product='" . $product_id . "' AND" . WPSC_TABLE_ALSO_BOUGHT . ".associated_product=" . $wpdb->posts . ".idAND" . $wpdb->posts . ".post_statusIN('publish','protected','inherit') ORDER BY" . WPSC_TABLE_ALSO_BOUGHT . ".quantityDESC) LIMIT $also_bought_limit", ARRAY_A );

    with this:

    $product_variation_ids = $wpdb->get_results("SELECT ID FROM" . $wpdb->posts . "WHEREpost_parent= " . $product_id . " ANDpost_type` = 'wpsc-product'" , ARRAY_A);
    $variation_ids = '';
    foreach ($product_variation_ids as $ids)
    $variation_ids = $ids['ID'] . "," . $variation_ids;

    $variation_ids= $variation_ids . $product_id;

    $also_bought = $wpdb->get_results( "SELECT " . $wpdb->posts . ".* FROM " . $wpdb->posts . " WHERE " . $wpdb->posts . ".id IN (SELECT " . $wpdb->posts . ".post_parent FROM " . WPSC_TABLE_ALSO_BOUGHT . ", " . $wpdb->posts . " WHERE selected_product IN ($variation_ids) AND " . WPSC_TABLE_ALSO_BOUGHT . ".associated_product = " . $wpdb->posts . ".id AND " . $wpdb->posts . ".post_status IN('publish','protected','inherit') ORDER BY " . WPSC_TABLE_ALSO_BOUGHT . ".quantity DESC) LIMIT $also_bought_limit", ARRAY_A );`

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic