Plugin Directory

Changeset 1229461


Ignore:
Timestamp:
08/24/2015 06:39:25 PM (11 years ago)
Author:
inigoini
Message:

Publishing version 1.4.3

Location:
thecartpress/trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • thecartpress/trunk/TheCartPress.class.php

    r1225478 r1229461  
    44Plugin URI: http://thecartpress.com
    55Description: Professional WordPress eCommerce Plugin. Use it as Shopping Cart, Catalog or Framework.
    6 Version: 1.4.2
     6Version: 1.4.3
    77Author: Pluginsmaker team
    88Author URI: http://pluginsmaker.com/
  • thecartpress/trunk/checkout/BillingBox.class.php

    r1152289 r1229461  
    7878                        $required = isset( $settings['required-' . $id] ) ? $settings['required-' . $id] : false;
    7979                        if ( $required && ( ! isset( $_REQUEST[$id] ) || strlen( $_REQUEST[$id] ) == 0 ) ) {
     80                           
     81                            // if not billing region id, take a look to region textbox
     82                            if ( $id == 'billing_region_id' ) {
     83                                if ( isset( $_REQUEST['billing_region'] ) && strlen( $_REQUEST['billing_region'] ) > 0 ) {
     84                                    continue;
     85                                }
     86                            }
    8087                            $this->errors[$id] = $field['error'];
    8188                        } elseif ( $id == 'billing_country_id' ) {
     
    568575        } ?>
    569576        <label for="billing_region_id"><?php _e( 'Region', 'tcp' ); ?>:<?php if ( $required ) echo '<em>*</em>'; ?></label>
    570         <?php $regions = apply_filters( 'tcp_load_regions_for_billing', false ); //array( 'id' => array( 'name'), 'id' => array( 'name'), ... ) ?>
     577        <?php //array( 'id' => array( 'name'), 'id' => array( 'name'), ... )
     578        $regions = apply_filters( 'tcp_load_regions_for_billing', false );
     579        ?>
    571580        <select id="billing_region_id" name="billing_region_id" <?php if ( is_array( $regions ) && count( $regions ) > 0 ) {} else { echo 'style="display:none;"'; }?> class="form-control">
    572581            <option value=""><?php _e( 'No state selected', 'tcp' ); ?></option>
  • thecartpress/trunk/checkout/ShippingBox.class.php

    r1152289 r1229461  
    7171                    $required = isset( $settings['required-' . $id] ) ? $settings['required-' . $id] : false;
    7272                    if ( $required && ( ! isset( $_REQUEST[$id] ) || strlen( $_REQUEST[$id] ) == 0 ) ) {
     73                       
     74                        // if not billing region id, take a look to region textbox
     75                        if ( $id == 'shipping_region_id' ) {
     76                            if ( isset( $_REQUEST['shipping_region'] ) && strlen( $_REQUEST['shipping_region'] ) > 0 ) {
     77                                continue;
     78                            }
     79                        }
    7380                        $this->errors[$id] = $field['error'];
    7481                    } elseif ( $id == 'shipping_country_id' ) {
     
    533540        } ?>
    534541        <label for="shipping_region_id"><?php _e( 'Region', 'tcp' ); ?>:<?php if ( $required ) echo '<em>*</em>'; ?></label>
    535         <?php $regions = apply_filters( 'tcp_load_regions_for_shipping', false ); //array( 'id' => array( 'name'), 'id' => array( 'name'), ... )    ?>
     542        <?php //array( 'id' => array( 'name'), 'id' => array( 'name'), ... )
     543        $regions = apply_filters( 'tcp_load_regions_for_shipping', false );
     544        ?>
    536545        <select id="shipping_region_id" name="shipping_region_id" <?php if ( is_array( $regions ) && count( $regions ) > 0 ) {} else { echo 'style="display:none;"'; }?> class="form-control">
    537546            <option value=""><?php _e( 'No state selected', 'tcp' ); ?></option>
  • thecartpress/trunk/classes/ShoppingCart.class.php

    r1200296 r1229461  
    766766    }
    767767
     768    /**
     769     * @deprecated deprecated since version 1.4.2
     770     */
    768771    function getOption1Id() {
    769772        return $this->option_1_id;
    770773    }
    771774
     775    /**
     776     * @deprecated deprecated since version 1.4.2
     777     */
    772778    function getOption2Id() {
    773779        return $this->option_2_id;
  • thecartpress/trunk/js/tcp_state_scripts.php

    r691701 r1229461  
    5353                    region_select.show();
    5454                }
    55                 jQuery('#region').hide();//textbox
     55
     56                // Hides region textbox
     57                jQuery('#region').hide();
    5658                region_select.val(jQuery('#region_selected_id').val());
    5759            } else {
    58                 jQuery('#region').show();//textbox
     60
     61                // Shows region textbox
     62                jQuery('#region').show();
    5963                region_select.hide();
    6064            }
     65            // Region textbox set to blank (always)
     66            jQuery('#region').val('');
    6167        });
    6268        jQuery('#country_id').change();
     
    8490                    region_select.show();
    8591                }
    86                 jQuery('#billing_region').hide();//textbox
     92
     93                // Hides region textbox
     94                jQuery('#billing_region').hide();
     95               
    8796                region_select.val(jQuery('#billing_region_selected_id').val());
    8897            } else {
    89                 jQuery('#billing_region').show();//textbox
     98                // Shows region textbox
     99                jQuery('#billing_region').show();
    90100                region_select.hide();
    91101            }
     102            // Region textbox set to blank
     103            jQuery('#billing_region').val('');
    92104        } );
    93105        jQuery('#billing_country_id').change();
     
    116128                    region_select.show();
    117129                }
    118                 jQuery('#shipping_region').hide();//textbox
     130
     131                // Hides region textbox
     132                jQuery('#shipping_region').hide();
    119133                region_select.val(jQuery('#shipping_region_selected_id').val());
    120134            } else {
    121                 jQuery('#shipping_region').show();//textbox
     135                // Shows region textbox
     136                jQuery('#shipping_region').show();
    122137                region_select.hide();
    123138            }
     139
     140            // Region textbox set to blank
     141            jQuery('#shipping_region').val('');
    124142        });
    125143        jQuery('#shipping_country_id').change();
  • thecartpress/trunk/modules/StockManagement.class.php

    r1152289 r1229461  
    4848            add_action( 'tcp_shopping_cart_widget_units'                , array( $this, 'tcp_shopping_cart_widget_units' ), 10, 2 );
    4949
    50             add_filter( 'tcp_cart_units'                                , array( $this, 'tcp_cart_units' ), 10, 2 );
     50            // Boths hooks for shopping cart lines
     51            add_action( 'tcp_cart_units'                                , array( $this, 'tcp_cart_units' ), 10, 2 );
     52            add_filter( 'tcp_shopping_cart_page_units'                  , array( $this, 'tcp_shopping_cart_page_units' ), 10, 2 );
    5153
    5254            add_action( 'tcp_shopping_cart_summary_widget_form'         , array( $this, 'tcp_shopping_cart_summary_widget_form' ), 10, 2 );
     
    5557            add_action( 'tcp_show_shopping_cart_summary_widget_params'  , array( $this, 'tcp_show_shopping_cart_summary_widget_params' ) );
    5658
    57             //add_filter( 'tcp_the_add_to_cart_unit_field'              , array( $this, 'tcp_the_add_to_cart_unit_field' ), 10, 2 );
    58 
     59            // Removes the unit fields if no units enough
     60            add_filter( 'tcp_the_add_to_cart_unit_field'                , array( $this, 'tcp_the_add_to_cart_unit_field' ), 10, 2 );
    5961            add_filter( 'tcp_the_add_to_cart_button'                    , array( $this, 'tcp_the_add_to_cart_button' ), 10, 2 );
    6062
     
    531533    }
    532534
     535    /**
     536     * Adds “out of stock" in the shopping cart lines, if no units enough
     537     *
     538     * @param $item, each line in the shoppingCart
     539     */
    533540    function tcp_cart_units( $item ) {
    534         global $thecartpress;
    535         $stock_management = $thecartpress->get_setting( 'stock_management', false );
    536         if ( $stock_management ) {
     541        //global $thecartpress;
     542        //$stock_management = $thecartpress->get_setting( 'stock_management', false );
     543        //if ( $stock_management ) {
    537544            $stock = tcp_get_the_stock( $item->get_post_id(), $item->get_option_1_id(), $item->get_option_2_id() );
    538545            ob_start();
     
    545552            <?php endif;
    546553            echo apply_filters( 'tcp_stock_cart_units', ob_get_clean(), $item->get_post_id() );
    547         }
     554        //}
     555    }
     556
     557    /**
     558     * Allows to change the unit field in the shopping cart
     559     *
     560     * @param $out
     561     * @param $order_detail
     562     */
     563    function tcp_shopping_cart_page_units( $out, $order_detail ) {
     564        $stock = tcp_get_the_stock( $order_detail->get_post_id() );
     565        //if ( $stock != -1 && $stock == $order_detail->get_qty_ordered() ) {
     566        if ( $stock == 1 ) {
     567            return $order_detail->get_qty_ordered();
     568        }
     569        return $out;
    548570    }
    549571
     
    760782    }
    761783
     784    /**
     785     * Removes the unit fields if no units enough, or hides the unit fields if only one unit is available
     786     *
     787     * @param $out
     788     * @param $post_id, product identifier
     789     */
    762790    function tcp_the_add_to_cart_unit_field( $out, $post_id ) {
    763         if ( tcp_get_the_stock( $post_id ) == 0 ) return '<span class="tcp_no_stock">' . __( 'Out of stock', 'tcp' ) . '</span>';
     791        $stock = tcp_get_the_stock( $post_id );
     792        if ( $stock == 0 ) {
     793            return '<span class="tcp_no_stock">' . __( 'Out of stock', 'tcp' ) . '</span>';
     794           
     795        // Since 1.4.3, if units in stock are less or equal to shopingcart, it hides the units fields
     796        } elseif ( $stock == 1 ) {
     797            return '<input type="hidden" name="tcp_count[]" id="tcp_count_' . $post_id . '" value="1" />';
     798        } elseif ( $stock > 1 ) {
     799            $shopingcart = thecartpress()->getShoppingCart();
     800            $item = $shopingcart->getItem( $post_id );
     801            if ( $item !== false ) {
     802                if ( $stock <= $item->getCount() ) {
     803                    return '<input type="hidden" name="tcp_count[]" id="tcp_count_' . $post_id . '" value="1" />';
     804                }
     805            }
     806        }
    764807        return $out;
    765808    }
    766809
    767810    function tcp_the_add_to_cart_button( $out, $post_id ) {
    768         if ( tcp_get_the_stock( $post_id ) == 0 ) return '<input type="hidden" name="tcp_post_id[]" id="tcp_post_id_' . $post_id . '" value="' . $post_id . '" />';
     811        $stock = tcp_get_the_stock( $post_id );
     812        if ( $stock == 0 ) {
     813            return '<input type="hidden" name="tcp_post_id[]" id="tcp_post_id_' . $post_id . '" value="' . $post_id . '" />';
     814
     815        // Since 1.4.3, if units in stock are less or equal to shopingcart, it hides the units fields
     816        } else if ( $stock > 0 ) {
     817            $shopingcart = thecartpress()->getShoppingCart();
     818            $item = $shopingcart->getItem( $post_id );
     819            if ( $item !== false ) {
     820                if ( $stock <= $item->getCount() ) {
     821                    return '<input type="hidden" name="tcp_post_id[]" id="tcp_post_id_' . $post_id . '" value="' . $post_id . '" />';
     822                }
     823            }
     824        }
    769825        return $out;
    770826    }
  • thecartpress/trunk/readme.txt

    r1225478 r1229461  
    66Requires at least: 3.3
    77Tested up to: 4.3
    8 Stable Tag: 1.4.2
     8Stable Tag: 1.4.3
    99Native eCommerce integration & interaction with WordPress. Flexibility & Scalability.
    1010Ideal for merchants, themes constructors and developers.
     
    299299
    300300== Changelog ==
     301= 1.4.3 =
     302* Checkout, Billing and Shopping steps: fix issue when region id is required and no regions list
     303* Stock manager: When only one unit (or units on stok are added to the shopping cart), hide the buy button and the units field
     304* WP 4.3 support
     305
    301306= 1.4.2 =
    302307* Internal improvements in searchs
  • thecartpress/trunk/templates/tcp_template.php

    r1152289 r1229461  
    14401440    $path = apply_filters( 'tcp_the_loop', $path, $loop );
    14411441
    1442     if ( $include ) include( $path );
    1443     else return $path;
     1442    if ( $include ) {
     1443        include( $path );
     1444    } else {
     1445        return $path;
     1446    }
    14441447}
    14451448
     
    14651468 */
    14661469function tcp_session_start( $time = 3600, $session_name = 'tcp' ) {
    1467     /*if ( session_id() == $session_name ) return;
    1468     session_set_cookie_params( $time );
    1469     session_name( $session_name );*/
    14701470    if ( ! session_id() ) session_start();
    1471 /*  if ( isset( $_COOKIE[$session_name] ) ) {
    1472         setcookie( $session_name, $_COOKIE[$session_name], time() + $time, null, null, true );
    1473         setcookie( $session_name, $_COOKIE[$session_name], time() + $time, null, null, false );
    1474     }*/
    14751471}
    14761472
    14771473function tcp_return_jsonp( $params ) {
    1478 
    1479 //  exit( $_REQUEST['callback'] . '(' . json_encode( $params ) . ')' );
    1480     //if ( is_array( $params ) ) $params = array( $params );
    1481 //var_dump( json_encode( $params ) );
    14821474    exit( json_encode( $params ) );
    14831475}
  • thecartpress/trunk/themes-templates/tcp_shopping_cart.php

    r1164243 r1229461  
    226226            <td class="tcp_cart_thumbnail">
    227227            <?php //$size = apply_filters( 'tcp_get_shopping_cart_image_size', array( 32, 32 ) );
    228             echo tcp_get_the_thumbnail( $order_detail->get_post_id(), $order_detail->get_option_1_id(), $order_detail->get_option_2_id() ); //, $size ); ?>
     228            echo tcp_get_the_thumbnail( $order_detail->get_post_id(), $order_detail->get_option_1_id(), $order_detail->get_option_2_id() ); ?>
    229229            </td>
    230230        <?php endif; ?>
  • thecartpress/trunk/widgets/ArchivesWidget.class.php

    r979914 r1229461  
    3131            'id_base'   => 'tcparchives-widget',
    3232        );
    33         $this->WP_Widget( 'tcparchives-widget', 'TCP Archives', $widget, $control );
     33        parent::__construct( 'tcparchives-widget', 'TCP Archives', $widget, $control );
    3434    }
    3535
  • thecartpress/trunk/widgets/AttributesListWidget.class.php

    r524619 r1229461  
    2828            'id_base'   => 'attributeslist-widget'
    2929        );
    30         $this->WP_Widget( 'attributeslist-widget', 'TCP Attributes List', $widget_settings, $control_settings );
     30        parent::__construct( 'attributeslist-widget', 'TCP Attributes List', $widget_settings, $control_settings );
    3131    }
    3232
  • thecartpress/trunk/widgets/BuyButtonWidget.class.php

    r627608 r1229461  
    2727            'id_base'   => 'buybutton-widget',
    2828        );
    29         $this->WP_Widget( 'buybutton-widget', 'TCP Buy Button', $widget, $control );
     29        parent::__construct( 'buybutton-widget', 'TCP Buy Button', $widget, $control );
    3030    }
    3131
  • thecartpress/trunk/widgets/CheckoutWidget.class.php

    r462585 r1229461  
    2828            'id_base'   => 'checkout-widget'
    2929        );
    30         $this->WP_Widget( 'checkout-widget', 'TCP Checkout', $widget_settings, $control_settings );
     30        parent::__construct( 'checkout-widget', 'TCP Checkout', $widget_settings, $control_settings );
    3131    }
    3232
  • thecartpress/trunk/widgets/CommentsCustomPostTypeWidget.class.php

    r791204 r1229461  
    3333            'id_base'   => 'commentscustomposttype-widget'
    3434        );
    35         $this->WP_Widget( 'commentscustomposttype-widget', 'TCP Comments for Custom Post Type', $widget_settings, $control_settings );
     35        parent::__construct( 'commentscustomposttype-widget', 'TCP Comments for Custom Post Type', $widget_settings, $control_settings );
    3636        //add_action( 'wp_unregister_sidebar_widget', array( $this, 'wpUnregisterSidebarWidget' ) );
    3737    }
  • thecartpress/trunk/widgets/LoginWidget.class.php

    r776872 r1229461  
    3333            'id_base'   => 'tcp_login-widget'
    3434        );
    35         $this->WP_Widget( 'tcp_login-widget', 'TCP Login Form', $widget_settings, $control_settings );
     35        parent::__construct( 'tcp_login-widget', 'TCP Login Form', $widget_settings, $control_settings );
    3636    }
    3737
  • thecartpress/trunk/widgets/SelectCountryWidget.class.php

    r705474 r1229461  
    2727            'id_base'   => 'tcpselectcountry-widget',
    2828        );
    29         $this->WP_Widget( 'tcpselectcountry-widget', 'TCP Select Country', $widget, $control );
     29        parent::__construct( 'tcpselectcountry-widget', 'TCP Select Country', $widget, $control );
    3030    }
    3131
  • thecartpress/trunk/widgets/ShoppingCartSummaryWidget.class.php

    r836081 r1229461  
    3636            'id_base'   => 'shoppingcartsummary-widget',
    3737        );
    38         $this->WP_Widget( 'shoppingcartsummary-widget', 'TCP Shopping Cart Summary', $widget, $control );
     38        parent::__construct( 'shoppingcartsummary-widget', 'TCP Shopping Cart Summary', $widget, $control );
    3939    }
    4040
  • thecartpress/trunk/widgets/ShoppingCartWidget.class.php

    r791204 r1229461  
    3333            'id_base'   => 'shoppingcart-widget',
    3434        );
    35         $this->WP_Widget( 'shoppingcart-widget', 'TCP Shopping Cart', $widget, $control );
     35        parent::__construct( 'shoppingcart-widget', 'TCP Shopping Cart', $widget, $control );
    3636    }
    3737
  • thecartpress/trunk/widgets/SortPanelWidget.class.php

    r478531 r1229461  
    2828            'id_base'   => 'sortpanel-widget'
    2929        );
    30         $this->WP_Widget( 'sortpanel-widget', 'TCP Sort Panel', $widget_settings, $control_settings );
     30        parent::__construct( 'sortpanel-widget', 'TCP Sort Panel', $widget_settings, $control_settings );
    3131    }
    3232
  • thecartpress/trunk/widgets/TCPParentWidget.class.php

    r979914 r1229461  
    3232            'id_base'   => $name . '-widget'
    3333        );
    34         $this->WP_Widget( $name . '-widget', $title, $widget_settings, $control_settings );
     34        parent::__construct( $name . '-widget', $title, $widget_settings, $control_settings );
    3535    }
    3636
Note: See TracChangeset for help on using the changeset viewer.