Plugin Directory

Changeset 2476144


Ignore:
Timestamp:
02/17/2021 08:22:31 AM (5 years ago)
Author:
mukkiee
Message:

version 1.2

Location:
ecommerce-table
Files:
49 added
6 edited

Legend:

Unmodified
Added
Removed
  • ecommerce-table/trunk/assets/ect_table_script.js

    r2472896 r2476144  
    6363                        $('.single_add_to_cart_button').prop('disabled', false);
    6464
    65                         alert(quantity+' '+$('.ect_title_'+product_id).children('a').text()+" has been added to cart");
     65                        var cart_quantity = parseInt($('.ectp_cart_contents_count').html());
     66
     67                        cart_quantity += parseInt(quantity);
     68
     69                        // $('.ectp_cart_contents_count').html(' '+cart_quantity);
     70
     71                        var notification = quantity+' '+$('.ect_title_'+product_id).children('a').text()+" has been added to cart";
     72
     73                        $('.ectp_notification').html(notification);
     74                       
     75                        $('.ectp_notification').css('display','block');
     76
     77                        $('.ectp_notification').css('background-color', '#229922');
     78
     79                        $( document.body ).trigger( 'wc_fragment_refresh' );
     80
     81                        setTimeout(function(){ $('.ectp_notification').css('display','none'); }, 4000);
    6682
    6783                    }
     
    85101                if(var_id == "0"){
    86102
    87                     alert("select options");
     103                    $('.ectp_notification').html('Select Options');
     104           
     105                    $('.ectp_notification').css('display','block');
     106
     107                    $('.ectp_notification').css('background-color', '#992222');
     108
     109                    setTimeout(function(){ $('.ectp_notification').css('display','none'); }, 4000);
    88110
    89111                    $('.single_add_to_cart_button').prop('disabled', false);
     
    113135                        success: function( data ) {
    114136
     137                            console.log(data);
     138
    115139                            if(data == 'added'){
    116140
    117141                                $('.single_add_to_cart_button').prop('disabled', false);
    118142
    119                                 alert(quantity+' '+$('.ect_title_'+product_id).children('a').text()+" has been added to cart");
     143                                var cart_quantity = parseInt($('.ectp_cart_contents_count').html());
    120144
     145                                cart_quantity += parseInt(quantity);
     146       
     147                                // $('.ectp_cart_contents_count').html(' '+cart_quantity);
     148                               
     149                                var notification = quantity+' '+$('.ect_title_'+product_id).children('a').text()+" has been added to cart";
     150
     151                                $('.ectp_notification').html(notification);
     152                       
     153                                $('.ectp_notification').css('display','block');
     154
     155                                $('.ectp_notification').css('background-color', '#229922');
     156
     157                                $( document.body ).trigger( 'wc_fragment_refresh' );
     158
     159                                setTimeout(function(){ $('.ectp_notification').css('display','none'); }, 4000);
     160       
    121161                            }
    122162
     
    129169            }else{
    130170
    131                 alert("select options");
     171                $('.ectp_notification').html('Select Options');
     172       
     173                $('.ectp_notification').css('display','block');
     174
     175                $('.ectp_notification').css('background-color', '#992222');
     176
     177                setTimeout(function(){ $('.ectp_notification').css('display','none'); }, 4000);
    132178
    133179                $('.single_add_to_cart_button').prop('disabled', false);
  • ecommerce-table/trunk/assets/ect_table_style.css

    r2472896 r2476144  
    1919.ect_table input.input-text {
    2020    width: 80%;
     21    padding: 0 !important;
     22    height: 40px;
     23    text-align: center;
    2124}
    2225
     
    2427    padding: 0px;
    2528    height: 42px;
    26     width: 100%;
     29    width: 96%;
    2730    align-self: center;
     31    font-size: 14px;
     32    font-weight: 100;
     33    margin: 0px 2%;
    2834}
    2935
     
    5763.ect_table>div {
    5864
    59     text-align: center;
     65    text-align: left;
    6066    margin: auto 0;
    6167
     
    7682.ect_table {
    7783
    78     padding: 10px 0;
     84    padding: 5px 0;
    7985
    8086}
     
    110116}
    111117
    112 .ect_table .variations .label {
     118.ect_table .variations td {
    113119
    114     margin-top: 5px!important;
     120    /* margin-top: 5px!important; */
     121    background-color: transparent !important;
    115122
    116123}
     
    121128
    122129}
     130
     131.ect_table .ectp_cart_align {
     132   
     133    display: grid;
     134    /* grid-template-columns: 7fr 3fr; */
     135    text-align: center;
     136
     137}
     138
     139.ect_table .ectp_align_right{
     140    text-align: right;
     141}
     142
     143.ect_table img.ectp_ajax_cart_image {
     144    width: 22px;
     145    display: inline-block;
     146}
     147
     148.ect_table .image_padding {
     149    padding-left: 20px;
     150}
     151
     152.ect_table .ect_price>p {
     153    display: inline-block;
     154}
     155
     156.ectp_notification {
     157    background-color: #229922;
     158    color: #fff;
     159    text-align: center;
     160    padding: 10px;
     161    position: fixed;
     162    top: 32px;
     163    z-index: 9999;
     164    width: 100%;
     165    left: 0;
     166    display: none;
     167}
  • ecommerce-table/trunk/includes/ect-add-to-cart.php

    r2472896 r2476144  
    11<?php
     2/**
     3 * Ecommerce Table.
     4 *
     5 * @package Ecommerce_Table
     6 * @author  Mukul Lodhi
     7 * @license GPL-2.0+
     8 *
     9 * @wordpress-plugin
     10 * Plugin Name: Ecommerce Table
     11 * Description: This Plugin displays products in tabular format * Author: Mukul Lodhi
     12 * Version: 1.2
     13 */
    214
    315if ( ! defined( 'ABSPATH' ) ) {
    4     exit; // Exit if accessed directly
     16    exit; // Exit if accessed directly.
    517}
    618
    7 if (!function_exists('ectp_generate_heading')) {
     19if ( ! function_exists( 'ectp_generate_heading' ) ) {
     20    /**
     21     * Function ectp_product_update.
     22     */
     23    function ectp_product_update() {
    824
    9     function ectp_product_update(){
     25        if ( isset( $_POST['nonce'] ) ) {
    1026
    11         if(isset($_POST['nonce'])){
     27            $nonce = sanitize_text_field( wp_unslash( $_POST['nonce'] ) );
    1228
    13             $nonce = sanitize_text_field( $_POST['nonce'] );
     29            if ( ! wp_verify_nonce( $nonce, 'ect-ajax-nonce' ) ) {
    1430
    15             if ( ! wp_verify_nonce( $nonce, 'ect-ajax-nonce' ) ) {
     31                die( 'Nonce value cannot be verified.' );
    1632
    17                 die( 'Nonce value cannot be verified.' );
     33            }
    1834
    19             }
     35            $product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( sanitize_text_field( wp_unslash( isset( $_POST['post_id'] ) ? $_POST['post_id'] : null ) ) ) );
    2036
    21             $product_id = apply_filters('woocommerce_add_to_cart_product_id', absint(sanitize_text_field( $_POST['post_id'] )));
     37            $quantity = empty( sanitize_text_field( wp_unslash( isset( $_POST['quantity'] ) ? $_POST['quantity'] : null ) ) ) ? 1 : wc_stock_amount( sanitize_text_field( wp_unslash( isset( $_POST['quantity'] ) ? $_POST['quantity'] : null ) ) );
    2238
    23             $quantity = empty(sanitize_text_field( $_POST['quantity'] )) ? 1 : wc_stock_amount(sanitize_text_field( $_POST['quantity'] ));
     39            $variation_id = absint( sanitize_text_field( wp_unslash( isset( $_POST['var_id'] ) ? $_POST['var_id'] : null ) ) );
    2440
    25             $variation_id = absint(sanitize_text_field( $_POST['var_id'] ));
     41            wc_stock_amount( sanitize_text_field( wp_unslash( isset( $_POST['quantity'] ) ? $_POST['quantity'] : null ) ) );
    2642
    27             wc_stock_amount(sanitize_text_field($_POST['quantity']));
     43            $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity );
    2844
    29             $passed_validation = apply_filters('woocommerce_add_to_cart_validation', true, $product_id, $quantity);
     45            $product_status = get_post_status( $product_id );
    3046
    31             $product_status = get_post_status($product_id);
     47            if ( $passed_validation && WC()->cart->add_to_cart( $product_id, $quantity, $variation_id ) && 'publish' === $product_status ) {
    3248
    33             if ($passed_validation && WC()->cart->add_to_cart($product_id, $quantity, $variation_id) && 'publish' === $product_status) {
     49                echo 'added';
    3450
    35                 echo 'added';
     51            } else {
    3652
    37             } else {
     53                $data = array(
    3854
    39                 $data = array(
     55                    'error'       => true,
    4056
    41                     'error' => true,
     57                    'product_url' => apply_filters( 'woocommerce_cart_redirect_after_error', get_permalink( $product_id ), $product_id ),
    4258
    43                     'product_url' => apply_filters('woocommerce_cart_redirect_after_error', get_permalink($product_id), $product_id));
     59                );
    4460
    45                 echo wp_send_json($data);
     61                echo esc_html( wp_send_json( $data ) );
    4662
    47             }
     63            }
    4864
    49             die();
     65            die();
    5066
    51         }
     67        }
    5268
    53         die();
     69        die();
    5470
    55     }
    56 
     71    }
    5772}
    5873add_action( 'wp_ajax_ectp_product_update', 'ectp_product_update' );
  • ecommerce-table/trunk/init.php

    r2472896 r2476144  
    1 <?php
    2 
    3 /*
    4 Plugin Name: Ecommerce Table
    5 Author: Mukul Lodhi
    6 Version: 1.1
    7 Requires at least: 5.5.3
    8 Tested up to: 5.6
    9 Description: This Plugin displays products in tabular format
    10 Requires PHP: 5.4
    11 License: GPLv2 or later
    12 License URI: http://www.gnu.org/licenses/gpl-2.0.html
    13 
    14 This Plugin arrange products into tabular format.
    15 
    16 */
     1<?php
     2/**
     3 * Plugin Name: Ecommerce Table
     4 * Author: Mukul Lodhi
     5 * Version: 1.2
     6 * Requires at least: 5.5.3
     7 * Tested up to: 5.6
     8 * Description: This Plugin displays products in tabular format
     9 * Requires PHP: 5.4
     10 * License: GPLv2 or later
     11 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
     12 *
     13 * This Plugin arrange products into tabular format.
     14 *
     15 * @package     Ecommerce_Table
     16 * @author      Mukul Lodhi
     17 * @license     GPL-2.0+
     18 */
    1719
    1820if ( ! defined( 'ABSPATH' ) ) {
    19     exit; // Exit if accessed directly
     21    exit; // Exit if accessed directly.
    2022}
    2123
    22 function activate_ect_Table() {
    23     require_once plugin_dir_path( __FILE__ ) . 'includes/ect-activator.php';
     24/** Functions to activate plugin */
     25function activate_ect_table() {
     26    require_once plugin_dir_path( __FILE__ ) . 'includes/class-ect-table-activator.php';
    2427    Ect_Table_Activator::activate();
    2528}
    26  
    27 function deactivate_ect_Table() {
    28     require_once plugin_dir_path( __FILE__ ) . 'includes/ect-deactivator.php';
     29
     30/** Functions to deactivate plugin */
     31function deactivate_ect_table() {
     32    require_once plugin_dir_path( __FILE__ ) . 'includes/class-ect-table-deactivator.php';
    2933    Ect_Table_Deactivator::deactivate();
    3034}
    31  
    32 register_activation_hook( __FILE__, 'activate_ect_Table' );
    33 register_deactivation_hook( __FILE__, 'deactivate_ect_Table' );
    34 register_uninstall_hook( __FILE__, 'deactivate_ect_Table' );
    3535
    36 require plugin_dir_path( __FILE__ ) . 'ect_table_functions.php';
     36register_activation_hook( __FILE__, 'activate_ect_table' );
     37register_deactivation_hook( __FILE__, 'deactivate_ect_table' );
     38register_uninstall_hook( __FILE__, 'deactivate_ect_table' );
     39
     40require plugin_dir_path( __FILE__ ) . 'includes/ect-table-functions.php';
  • ecommerce-table/trunk/readme.txt

    r2473153 r2476144  
    44Requires at least: 5.5.3
    55Tested up to: 5.6
    6 Stable tag: trunk
     6Stable tag: 1.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1818Features:
    1919
    20 * Option to set number of products to display in table
    21 * Option to set size or product images to display
    22 * Option in front end to sort products using categories and tags
    23 * Option to display featured and instock products
    24 * Separated admin menu for customization
     20* Option to set number of products to display in table.
     21* Option to change order of columns.
     22* Option to set size or product images to display.
     23* Option in front end to sort products using categories and tags.
     24* Option to sort display featured and instock products.
     25* Separated admin menu for customization.
    2526* Supports multiple product types, plugin handles any type of product.
    26 * Clean layout
    27 * Not obstructive
     27* Clean layout.
     28* Not obstructive.
    2829
    2930*Perfect tool to display tabular products.*
     
    3637
    3738== Frequently asked questions ==
    38 = A question that someone might have =
    39 An answer to that question.
    4039
    4140
    4241== Screenshots ==
    43 1. Admin options
    44 2. Front end preview
     421. admin-options.png
     432. table.png
    4544
    4645
     
    4948Version 1.0: initial release
    5049Version 1.1: final release
     50Version 1.2: Added multiple features
    5151
    5252
Note: See TracChangeset for help on using the changeset viewer.