Plugin Directory

Changeset 1014404


Ignore:
Timestamp:
10/26/2014 11:29:44 PM (11 years ago)
Author:
ulih
Message:

Version 2.1.0
Enhancements and bugfixes

Location:
woocommerce-poor-guys-swiss-knife
Files:
141 added
3 edited

Legend:

Unmodified
Added
Removed
  • woocommerce-poor-guys-swiss-knife/trunk/classes/woocommerce-poor-guys-swiss-knife.php

    r1004165 r1014404  
    55 *
    66 * @class       WCPGSK_Main
    7  * @version     1.3
     7 * @version     1.4
    88 * @package     WooCommerce-Poor-Guys-Swiss-Knife/Classes
    99 * @category    Class
     
    4545                $wcpgsk_about = new WCPGSK_About( $this->file );
    4646                //add_action( 'add_meta_boxes', array($this, 'wcpgsk_add_meta_box_minmaxstep'), 10 );
     47                add_action('woocommerce_product_options_general_product_data', array( $this, 'wcpgsk_set_price_html' ), 99 );
     48               
    4749                add_action( 'woocommerce_product_write_panel_tabs', array( $this, 'wcpgsk_product_write_panel_tab' ), 99 );
    4850                add_action( 'woocommerce_product_write_panels',     array( $this, 'wcpgsk_product_write_panels' ), 99 );
     
    108110            add_action( 'woocommerce_init', array( $this, 'wcpgsk_empty_cart' ), PHP_INT_MAX );
    109111            add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'wcpgsk_checkout_update_order_meta' ), 10, 2 );
     112           
     113            add_filter('woocommerce_get_price_html', array( $this, 'wcpgsk_get_price_html' ), 10, 2 );
     114            add_filter('woocommerce_empty_price_html', array( $this, 'wcpgsk_empty_price_html' ), PHP_INT_MAX, 2);
     115            add_filter('woocommerce_free_sale_price_html', array( $this, 'wcpgsk_free_sale_price_html' ), PHP_INT_MAX, 2);
     116            add_filter('woocommerce_free_price_html', array( $this, 'wcpgsk_free_price_html' ), PHP_INT_MAX, 2);
     117           
    110118        }
    111119
     
    160168         */
    161169        public function wcpgsk_sale_flash( $flash, $post, $product ) {
    162             $options = get_option( 'wcpgsk_settings' );
     170            $options = get_option( 'wcpgsk_settings' );                 
     171            //$lp = get_product( $product->post->ID );
     172            if ( $product->get_price() === '' || $product->get_price() == 0 ) :
     173                return '';
     174            endif;         
     175            $product_id = $product->post->ID;
     176            $onsale_label = get_post_meta($product_id, '_wcpgsk_onsale_html', true);
     177            if ( isset( $onsale_label ) && !empty( $onsale_label ) ) :
     178                return '<span class="onsale">' . __( $onsale_label, WCPGSK_DOMAIN ) . '</span>';
     179            endif;
     180           
    163181            if ( isset( $options['process']['onsalelabel'] ) && !empty( $options['process']['onsalelabel'] ) ) :
    164182                $flash = '<span class="onsale">' . __( $options['process']['onsalelabel'], WCPGSK_DOMAIN ) . '</span>';
     
    255273        }
    256274
     275       
     276        /**
     277         * Add extended amount information
     278         *
     279         * @since 2.1.0
     280         *
     281         * @access public
     282         * @output fields
     283         */
     284        public function wcpgsk_set_price_html() {
     285            woocommerce_wp_text_input(array('id' => '_wcpgsk_extend_price', 'label' => __('Specify extended price data', WCPGSK_DOMAIN) ));
     286            $placements = array(
     287                'after' => __( 'After price', WCPGSK_DOMAIN ),
     288                'before' => __( 'Before price', WCPGSK_DOMAIN ),
     289                'newline' => __( 'On newline', WCPGSK_DOMAIN ),
     290            );
     291            woocommerce_wp_select(array('id' => '_wcpgsk_extend_price_placement', 'label' => __('Select placement of extended price data', WCPGSK_DOMAIN), 'options' => $placements ));
     292            woocommerce_wp_text_input(array('id' => '_wcpgsk_onsale_html', 'label' => __('Specify on sale label', WCPGSK_DOMAIN) ));
     293            woocommerce_wp_text_input(array('id' => '_wcpgsk_empty_price_html', 'label' => __('Specify empty price label', WCPGSK_DOMAIN) ));
     294            woocommerce_wp_text_input(array('id' => '_wcpgsk_free_price_html', 'label' => __('Specify free price label', WCPGSK_DOMAIN) ));
     295            woocommerce_wp_text_input(array('id' => '_wcpgsk_free_sale_html', 'label' => __('Specify free sales label', WCPGSK_DOMAIN) ));
     296        }
     297       
     298        /**
     299         * Display extended price information
     300         *
     301         * @since 2.1.0
     302         *
     303         * @access public
     304         * @param string $price
     305         * @param mixed $product
     306         * @return string $price extended
     307         */
     308        public function wcpgsk_get_price_html($price, $product) {
     309            $product_id = $product->post->ID;
     310            $extend_price_data = get_post_meta($product_id, '_wcpgsk_extend_price', true);
     311            if ( isset( $extend_price_data ) && !empty( $extend_price_data ) ) :
     312                $extend_price_placement = get_post_meta($product_id, '_wcpgsk_extend_price_placement', true);
     313                switch ( $extend_price_placement ) :
     314                    case "before" :
     315                        $price = '<span class="wcpgsk-extend-price-data">' . __( $extend_price_data, WCPGSK_DOMAIN ) . '</span> ' . $price;
     316                    break;
     317                    case "newline" :
     318                        $price = $price . '<div class="wcpgsk-extend-price-data">' . __( $extend_price_data, WCPGSK_DOMAIN ) . '</div>';
     319                    break;
     320                    default :
     321                        $price = $price . ' <span class="wcpgsk-extend-price-data">' . __( $extend_price_data, WCPGSK_DOMAIN ) . '</span>';                     
     322                    break;
     323                endswitch;
     324            endif;
     325
     326            return $price;
     327        }
     328
     329        /**
     330         * Display empty price label if defined as label or for product
     331         *
     332         * @since 2.1.0
     333         *
     334         * @access public
     335         * @param string $empty
     336         * @param mixed $product
     337         * @return string $price label for empty
     338         */
     339        public function wcpgsk_empty_price_html( $empty, $product ) {
     340            $options = get_option( 'wcpgsk_settings' );     
     341            $product_id = $product->post->ID;
     342            $g_empty_price = isset( $options['process']['empty_price_html'] ) && !empty( $options['process']['empty_price_html'] ) ? $options['process']['empty_price_html'] : '';
     343            $p_empty_price = get_post_meta($product_id, '_wcpgsk_empty_price_html', true);
     344            if ( isset( $p_empty_price ) && !empty( $p_empty_price ) ) :
     345                return $p_empty_price;
     346            endif;
     347            return $g_empty_price;
     348        }
     349
     350        /**
     351         * Display free sales price label if defined for a product
     352         *
     353         * @since 2.1.0
     354         *
     355         * @access public
     356         * @param string $empty
     357         * @param mixed $product
     358         * @return string $price label for empty
     359         */
     360        public function wcpgsk_free_sale_price_html( $price, $product ) {
     361            $product_id = $product->post->ID;
     362            $free_sales_label = get_post_meta($product_id, '_wcpgsk_free_sale_html', true);
     363            if ( isset( $free_sales_label ) && !empty( $free_sales_label ) ) :
     364                $price = str_replace( __( 'Free!', 'woocommerce' ), __( $free_sales_label, WCPGSK_DOMAIN ), $price );
     365            endif;
     366            return $price;
     367        }
     368
     369        /**
     370         * Display free price label if defined for a product
     371         *
     372         * @since 2.1.0
     373         *
     374         * @access public
     375         * @param string $empty
     376         * @param mixed $product
     377         * @return string $price label for empty
     378         */
     379        public function wcpgsk_free_price_html( $price, $product ) {
     380            $product_id = $product->post->ID;
     381            $free_price_label = get_post_meta($product_id, '_wcpgsk_free_price_html', true);
     382            if ( isset( $free_price_label ) && !empty( $free_price_label ) ) :
     383                $price = __( $free_price_label, WCPGSK_DOMAIN );
     384            endif;
     385            return $price;
     386        }
     387       
    257388        /**
    258389         * Label configuration settings
     
    467598                        </td>
    468599                    </tr>
     600                    <tr>
     601                        <td><?php _e('Define empty price label', WCPGSK_DOMAIN); ?>:</td>
     602                        <td>
     603                            <input name="wcpgsk_settings[process][empty_price_html]" type="text" class="wcpgsk_textfield" value="<?php if (!empty($options['process']['empty_price_html'])) echo esc_attr( $options['process']['empty_price_html'] ); ?>" class="regular-text" />
     604                        </td>
     605                        <td>
     606                            <span class="description"><?php _e('Define a empty price label.', WCPGSK_DOMAIN); ?></span>
     607                        </td>
     608                    </tr>
    469609                    <?php do_action( 'wcpgsk_settings_labels_after', $options ); ?>                 
    470610                </tbody>
     
    497637         *
    498638         * @since 1.9.2
    499          * @changed 1.9.83
     639         * @changed 2.1.0
    500640         * @return configured string value
    501641         */
     
    848988                update_post_meta( $post_id, '_wcpgsk_stepqty', $stepqty );
    849989            endif;
     990            if ( isset( $_POST['_wcpgsk_extend_price'] ) && $_POST['_wcpgsk_extend_price'] ) :
     991                update_post_meta( $post_id, '_wcpgsk_extend_price', wp_kses_post( $_POST['_wcpgsk_extend_price'] ) );
     992                update_post_meta( $post_id, '_wcpgsk_extend_price_placement', $_POST['_wcpgsk_extend_price_placement'] );           
     993            else :
     994                update_post_meta( $post_id, '_wcpgsk_extend_price', '' );
     995                update_post_meta( $post_id, '_wcpgsk_extend_price_placement', 'after' );               
     996            endif;
     997            if ( isset( $_POST['_wcpgsk_empty_price_html'] ) && $_POST['_wcpgsk_empty_price_html'] ) :
     998                update_post_meta( $post_id, '_wcpgsk_empty_price_html', wp_kses_post( $_POST['_wcpgsk_empty_price_html'] ) );           
     999            else :
     1000                update_post_meta( $post_id, '_wcpgsk_empty_price_html', '' );           
     1001            endif;
     1002            if ( isset( $_POST['_wcpgsk_free_sale_html'] ) && $_POST['_wcpgsk_free_sale_html'] ) :
     1003                update_post_meta( $post_id, '_wcpgsk_free_sale_html', wp_kses_post( $_POST['_wcpgsk_free_sale_html'] ) );           
     1004            else :
     1005                update_post_meta( $post_id, '_wcpgsk_free_sale_html', '' );         
     1006            endif;
     1007            if ( isset( $_POST['_wcpgsk_free_price_html'] ) && $_POST['_wcpgsk_free_price_html'] ) :
     1008                update_post_meta( $post_id, '_wcpgsk_free_price_html', wp_kses_post( $_POST['_wcpgsk_free_price_html'] ) );         
     1009            else :
     1010                update_post_meta( $post_id, '_wcpgsk_free_price_html', '' );           
     1011            endif;
     1012            if ( isset( $_POST['_wcpgsk_onsale_html'] ) && $_POST['_wcpgsk_onsale_html'] ) :
     1013                update_post_meta( $post_id, '_wcpgsk_onsale_html', wp_kses_post( $_POST['_wcpgsk_onsale_html'] ) );         
     1014            else :
     1015                update_post_meta( $post_id, '_wcpgsk_onsale_html', '' );           
     1016            endif;
     1017           
    8501018        }
    8511019
     
    11891357            }
    11901358            do_action( 'wcpgsk_settings_update', $options );
    1191            
    11921359            // Now display the settings editing screen
    11931360            //get some reused labels
     
    23792546                    $address[$key]['required'] = false;
    23802547
    2381                 elseif ( $key == 'billing_email_validator' ) :
    2382                     $address[$key]['custom_attributes'] = array('style' => 'display:none');
    2383                     $address[$key]['label'] = '';
    2384                     $address[$key]['required'] = false;
     2548                //elseif ( $key == 'billing_email_validator' ) :
     2549                    //$address[$key]['custom_attributes'] = array('style' => 'display:none');
     2550                    //$address[$key]['label'] = '';
     2551                    //$address[$key]['required'] = false;
    23852552                else :
    23862553                   
     
    41464313                        'onsalelabel' => 'Sale!',
    41474314                        'emptycartlabel' => 'Empty cart?',
    4148                         'confirmemptycart' => 'Yes, empty cart'),
     4315                        'confirmemptycart' => 'Yes, empty cart',
     4316                        'empty_price_html' => ''),
    41494317                    'email' => array(
    41504318                        'wc_cc_email' => '',
  • woocommerce-poor-guys-swiss-knife/trunk/readme.txt

    r1006962 r1014404  
    22Contributors: ulih
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KJ4K2X953H8CC
    4 Tags: WooCommerce checkout manager, WooCommerce cart manager, quantity management, file upload, color picker, WooCommerce color picker, WooCommerce file upload, cart manager, checkout manager, checkout, cart, shop, WooCommerce, shop settings, cart settings, checkout settings, variations bulk manager, variations manager, minimum items, maximum items, quantity input, product quantities, incremental quantities, minimum quantity, maximum quantity, wholesale, checkout personalization, checkout form, checkout customization, custom forms, custom fields, confirmation, confirmation fields, cart button, payment gateways, payment gateways customization, gateways, shipping, field editor, field, buy, pay, bulk management, variations, variation extender, custom fields per product, custom fields per variation, checkout localization, WooCommerce labels, WooCommerce email recipients, priceable extras, member registration, extras, product extras
     4Tags: WooCommerce checkout manager, WooCommerce cart manager, quantity management, file upload, color picker, WooCommerce color picker, WooCommerce file upload, cart manager, checkout manager, checkout, cart, shop, WooCommerce, shop settings, cart settings, checkout settings, variations bulk manager, variations manager, minimum items, maximum items, quantity input, product quantities, incremental quantities, minimum quantity, maximum quantity, wholesale, checkout personalization, checkout form, checkout customization, custom forms, custom fields, confirmation, confirmation fields, cart button, payment gateways, payment gateways customization, gateways, shipping, field editor, field, buy, pay, bulk management, variations, variation extender, custom fields per product, custom fields per variation, checkout localization, WooCommerce labels, WooCommerce email recipients, priceable extras, member registration, extras, product extras, price labels, custom price labels
    55Requires at least: Wordpress 3.1 and WooCommerce 2.0
    66Tested up to: 4.0
    7 Stable tag: 2.0.2
     7Stable tag: 2.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4545* Manage available payment gateways on a per product basis with intelligent filter to show the most restrictive combination when a customer has more than one product in his cart
    4646* Add one cc and one bcc email to all emails send by WooCommerce
     47* Price labels including labels for free price and free sales price on a per product basis
     48* Extend all price labels appending or prefixing your text on a per product basis
    4749
    4850Cart:
     
    8991= What's new? =
    9092
     93* Manage price labels on per product basis
    9194* WooCommerce 2.2 compatibility
    9295* input pattern attribute support with fallback for Safari browser 
     
    298301== Changelog ==
    299302
     303= 2.1.0 =
     304
     305* Bugfix: A required email validator caused an error when editing the billing address on the "My Account" page
     306* Enhancement: Override "On Sale" label on per product basis
     307* Enhancement: Extend product price on per product basis
     308* Enhancement: Set free labels (for regular price and on sale price) on per product basis
     309
    300310= 2.0.2 =
    301311
  • woocommerce-poor-guys-swiss-knife/trunk/woocommerce-poor-guys-swiss-knife.php

    r1006889 r1014404  
    88 * Author: Uli Hake
    99 * Author URI: http://takebarcelona.com/authorship/uli-hake
    10  * Version: 2.0.2
     10 * Version: 2.1.0
    1111 * @package WordPress
    1212 * @subpackage WooCommerce Poor Guys Swiss Knife
     
    121121        //load into our global
    122122        $wcpgsk = new WCPGSK_Main( __FILE__ );
    123         $wcpgsk->version = '2.0.2';
     123        $wcpgsk->version = '2.1.0';
    124124        $wcpgsk->wcpgsk_hook_woocommerce_filters();
    125125       
     
    133133}
    134134}
    135 /*
    136 * obsolete
    137 if ( !function_exists('wcpgsk_load_wcsession_helper') ) {
    138 // @changed 1.5.4 because we do not support WooCommerce < 2.0
    139 function wcpgsk_load_wcsession_helper() {
    140     global $wcpgsk_name, $wcpgsk_session, $woocommerce;
    141     if ( !is_admin() ) :
    142         //require_once( 'classes/woocommerce_session_helper.php' );
    143         $wcpgsk_session = $woocommerce->session;// new WooCommerce_Session_Helper( __FILE__ );
    144     endif; 
    145 }
    146 }
    147 */
    148135
    149136add_action( 'after_setup_theme', 'wcpgsk_template_functions', 1 );
Note: See TracChangeset for help on using the changeset viewer.