WordPress.org

Plugin Directory

Changeset 560942


Ignore:
Timestamp:
06/20/12 05:17:10 (22 months ago)
Author:
JustinSainton
Message:

Tagging 1.0.1

Location:
wp-e-commerce-bulk-category-pricing
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • wp-e-commerce-bulk-category-pricing/trunk/readme.txt

    r429198 r560942  
    11=== Plugin Name === 
    2 Contributors: justinsainton 
    3 Donate link: http://example.com/ 
     2 
     3Contributors: JustinSainton 
     4 
     5Donate link: http://zaowebdesign.com 
     6 
    47Tags: wp-e-commerce, e-commerce, wordpress e-commerce, categories, pricing 
    5 Requires at least: 3.0 
    6 Tested up to: 3.2.1 
    7 Stable tag: 1.0 
     8 
     9Requires at least: 3.3 
     10 
     11Tested up to: 3.4 
     12 
     13Stable tag: 1.0.1 
    814 
    915== Description == 
    1016 
     17 
     18 
    1119This plugin allows WP E-Commerce store admins to select certain categories as 'bulk pricing' categories, add a product threshold and discount to that category.  On the front-end, when any combination of products from one of these categories is in the shopping cart, and has met or exceeded the specified threshold, the specified discount is applied to each product. 
     20 
     21 
    1222 
    1323== Installation == 
    1424 
     25 
     26 
    15271. Upload `wpec_bulk_cat.php` to the `/wp-content/plugins/` directory 
     28 
    16292. Activate the plugin through the 'Plugins' menu in WordPress 
     30 
    17313. Go to Product Categories and edit category meta as necessary. 
     32 
     33 
    1834 
    1935== Frequently Asked Questions == 
    2036 
    21 None yet. 
     37None yet.  Props to jn0101 for initial patches for multiple category support. 
     38 
    2239 
    2340== Changelog == 
    2441 
     421.0.1 
     43 
     44* Adds ability for multiple category assignment, also tiered category pricing (different bulk rates per category at different cart totals for said category) 
     45 
    25461.0 
     47 
    2648* Initial commit 
     49 
    2750 
    2851== Screenshots == 
    2952 
     53 
     54 
    3055None yet. 
  • wp-e-commerce-bulk-category-pricing/trunk/wpec_bulk_cat.php

    r429192 r560942  
    1313class WPEC_Bulk_Category_Pricing { 
    1414 
    15     var $discount = 0; 
     15    private $discount = 0; 
    1616 
    1717    public function __construct() { 
     
    8989        <tr class="form-field"> 
    9090            <th scope="row" valign="top"> 
    91         <label><?php _e( 'This category uses bulk pricing.', 'wpsc-bulk-category' ); ?></label> 
     91        <label><?php _e( 'This category uses bulk pricing.', 'wpsc-bulk-category' ); ?></label> 
    9292            </th> 
    9393            <td> 
     
    9595                <input type="radio" class="wpsc_cat_box" value='0' name="use_bulk_pricing" <?php checked( '0', $use_bulk_pricing ); ?> /><?php _e( 'No', 'wpsc-bulk-category' ); ?> 
    9696                <br /> 
    97       </td> 
    98     </tr> 
     97      </td> 
     98    </tr> 
    9999 
    100100        <tr class="form-field"> 
    101101            <th scope="row" valign="top"> 
    102         <label><?php _e( 'Bulk pricing threshold.  Specify how many products in this category need to be in the shopping cart before the discount is applied.', 'wpsc-bulk-category' ); ?></label> 
     102        <label><?php _e( 'Bulk pricing threshold.  Specify how many products in this category need to be in the shopping cart before the discount is applied.', 'wpsc-bulk-category' ); ?></label> 
    103103            </th> 
    104104            <td> 
     
    106106                <br /> 
    107107            </td> 
    108     </tr> 
     108    </tr> 
    109109 
    110110        <tr class="form-field"> 
    111111            <th scope="row" valign="top"> 
    112         <label><?php _e( 'Bulk pricing discount.  Specify, in specific currency (e.g. 1.99) what the discount per product should be.', 'wpsc-bulk-category' ); ?></label> 
     112        <label><?php _e( 'Bulk pricing discount.  Specify, in specific currency (e.g. 1.99) what the discount per product should be.', 'wpsc-bulk-category' ); ?></label> 
    113113            </th> 
    114114            <td> 
     
    116116                <br /> 
    117117            </td> 
    118     </tr> 
     118    </tr> 
    119119 
    120120        <?php 
     
    150150        $bulk = false; 
    151151 
    152         foreach( $category_ids as $id ) { 
     152        foreach( $category_ids as $id ) 
    153153            if( in_array( $id, $bulk_categories  ) ) 
    154154                $bulk = true; 
    155         } 
    156155 
    157156        if( ! $bulk ) 
     
    162161        $eligible_products = array(); 
    163162 
    164         foreach( $wpsc_cart->cart_items as $item ) { 
    165  
    166             if( ! in_array( $item->category_id_list[0], $bulk_categories ) ) 
    167                 continue; 
    168             $eligible_products[$item->category_id_list[0]]['quantity'][$item->product_id] = $item->quantity; 
    169  
    170         } 
    171  
     163        foreach( $wpsc_cart->cart_items as $item ) 
     164            foreach( $item->category_id_list as $cid ) 
     165                if( in_array( $cid, $bulk_categories ) ) 
     166                    $eligible_products[$cid]['quantity'][$item->product_id] = $item->quantity; 
     167         
    172168        //Loop de doop 
    173169 
     
    182178             
    183179        } 
    184          
     180 
    185181        return $eligible_products; 
    186          
    187     } 
    188  
    189     public function modify_price($price, $product_id) { 
     182    } 
     183 
     184 
     185 
     186    public function modify_price( $price, $product_id ) { 
    190187 
    191188        $object_terms = wp_get_object_terms( $product_id, 'wpsc_product_category' ); 
    192         //echo '<pre>' . print_r( $this->is_item_bulk( $product_id ), 1 ) . '</pre>'; 
    193  
    194         //If no items in cart are in bulk categories, just return the price 
    195         if( ! $this->is_item_bulk( $product_id ) ) 
    196             return $price; 
    197189 
    198190        //If is_item_bulk method is populated, it's populated with an array of the categories 
    199191        $eligible_products = $this->is_item_bulk( $product_id ); 
    200  
    201         //Check which category the product is in. 
    202          
    203         $cat_id = $object_terms[0]->term_id; 
    204  
    205         //echo '<pre>' . print_r( $eligible_products, 1 ) . '</pre>'; 
    206              
    207        $price = $price - $eligible_products[$cat_id]['discount']; 
     192         
     193        //If no items in cart are in bulk categories, just return the price 
     194        if( ! $eligible_products ) 
     195            return $price; 
     196         
     197        //Loop through and subtract discount from eligible items 
     198        foreach( $object_terms as $term ) 
     199          $price = $price - $eligible_products[$term->term_id]['discount']; 
    208200 
    209201       unset( $eligible_products ); 
    210202 
    211203       return $price; 
    212  
    213     } 
     204    } 
     205 
    214206 
    215207    public function refresh_cart() { 
     
    224216        } 
    225217    } 
    226  
    227218} 
    228219 
Note: See TracChangeset for help on using the changeset viewer.