Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • why don’t you please post the changes?

    I had problems with the category name for the permalink and old database entries (for the pics). Setup was: WordPress 2.8.4, WP Shopping Cart 3.7.4, Random Product 1.2.

    Solved it by replacing this:

    $random_product_id = rand(1, end($product_count));
    while(!$random_product){
    $random_product = $wpdb->get_row("SELECT * FROM $wpsc_product_list WHERE id = $random_product_id");
    }
    $random_product_category = $wpdb->get_var("SELECT category_id FROM $wpsc_product_order WHERE product_id = $random_product_id");
    $random_product_category_nice_name = $wpdb->get_var("SELECT <code>nice-name</code> FROM $wpsc_product_categories WHERE <code>id</code> = $random_product_id");
    $random_product_image = $wpdb->get_var("SELECT image FROM $wpsc_product_image WHERE product_id = $random_product_id");

    with this:

    // the.acidfarm.org
    // Basti Rotamente solution begin
    $res = $wpdb->get_col("SELECT id FROM $wpsc_product_list WHERE active = 1 AND publish = 1");
    $random_pos = rand(0, count($res)-1);
    $random_product_id = $res[$random_pos];
    $random_product = $wpdb->get_row("SELECT * FROM $wpsc_product_list WHERE id = $random_product_id");
    $random_product_category_nice_name = $wpdb->get_var("SELECT <code>nice-name</code> FROM $wpsc_product_categories LEFT JOIN $wpsc_product_order ON $wpsc_product_order.category_id = $wpsc_product_categories.id WHERE $wpsc_product_order.product_id = $random_product_id AND active = 1");
    // Basti Rotamente solution end
    // letztes foto
    $random_product_image = $wpdb->get_var("SELECT image FROM $wpsc_product_image WHERE product_id = $random_product_id ORDER BY image_order DESC" );

    Then the plugin will use the last of multiple pics. Sometimes I needed to add the thumbnails manually (depending on how pics are added and arranged to the product).

Viewing 2 replies - 1 through 2 (of 2 total)