WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: WPEC Bulk Category Pricing] Your plugin breaks if more than one category

[Resolved] [Plugin: WPEC Bulk Category Pricing] Your plugin breaks if more than one category

  • Please, code like

    if( ! in_array( $item->category_id_list[0], $bulk_categories ) )
                    continue;
                $eligible_products[$item->category_id_list[0]]['quantity'][$item->product_id] = $item->quantity;

    just screams to break. Initially users are happy… then they work on their products, add categories and boom…. your plugin doesent work anymore, or actually worse, sometimes break, sometimes doesent, depending on whether you are lucky that the bulk category ID is in $item->category_id_list[0] and not in $item->category_id_list[1].

    You need to use inner loops:

    foreach( $item->category_id_list as $cid ) {
    error_log('i2  id_list '. $cid);
                if( in_array( $cid, $bulk_categories ) ) {
                  $eligible_products[$cid]['quantity'][$item->product_id] = $item->quantity;
                }
              }

    Also here:

    //Check which category the product is in.
    
            $cat_id = $object_terms[0]->term_id;

    needs to be something like:

    foreach( $object_terms as $term ) {
              $cat_id = $term->term_id;
              $price = $price - $eligible_products[$cat_id]['discount'];
            }

    http://wordpress.org/extend/plugins/wp-e-commerce-bulk-category-pricing/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] [Plugin: WPEC Bulk Category Pricing] Your plugin breaks if more than one category’ is closed to new replies.