Plugin Directory

Changeset 3072117


Ignore:
Timestamp:
04/17/2024 07:06:13 AM (22 months ago)
Author:
nikitasolanki1812
Message:

Remove product discount new feature release on version 1.1

Location:
bulk-woo-discount
Files:
15 added
3 edited

Legend:

Unmodified
Added
Removed
  • bulk-woo-discount/trunk/admin/class-bwdp-admin.php

    r3036517 r3072117  
    126126    public function bwdp_register_actions( $bulk_actions ) {
    127127        $bulk_actions['product-discount-action'] = __( 'Product discount', 'bulk-woo-discount' );
     128        $bulk_actions['product-removediscount-action'] = __( 'Remove discount', 'bulk-woo-discount' );
    128129        return $bulk_actions;
    129130    }
     
    139140     */
    140141    public function bwdp_action_handler( $redirect_to, $doaction, $post_ids ) {
    141         if ( 'product-discount-action' !== $doaction ) {
    142             return $redirect_to;
    143         }
    144 
    145         $bwdp_price = get_option( 'bwdp_price' );
    146         if ( ! empty( $bwdp_price ) ) {
     142        if ( 'product-discount-action' === $doaction ) {
     143            $bwdp_price = get_option( 'bwdp_price' );
     144            if ( ! empty( $bwdp_price ) ) {
     145                foreach ( $post_ids as $post_id ) {
     146                    update_post_meta( $post_id, 'bwdp-product-discount', $bwdp_price );
     147                }
     148            }
     149            $redirect_to = add_query_arg( 'bulk_product-discount', count( $post_ids ), $redirect_to );
     150        }
     151        if ( 'product-removediscount-action' === $doaction ) {
    147152            foreach ( $post_ids as $post_id ) {
    148                 update_post_meta( $post_id, 'bwdp-product-discount', $bwdp_price );
    149             }
    150         }
    151         $redirect_to = add_query_arg( 'bulk_product-discount', count( $post_ids ), $redirect_to );
     153                update_post_meta( $post_id, 'bwdp-product-discount', null );
     154            }
     155            $redirect_to = add_query_arg( 'bulk_product-discount', count( $post_ids ), $redirect_to );
     156        }
    152157        return $redirect_to;
    153158    }
     
    278283
    279284    /**
     285     * Add custom column to the admin table for Products post type.
     286     *
     287     * @param array $columns Columns array.
     288     * @return array Modified columns array.
     289     * @package Bulk_Woo_Discount
     290     * @since 1.0.0
     291     */
     292    public function bwdp_columns_head($columns) {
     293        $new_columns = array();
     294        // Copy existing columns
     295        foreach ($columns as $key => $value) {
     296            $new_columns[$key] = $value;
     297            if ($key === 'sku') {
     298                // Add custom column after 'sku' column
     299                $new_columns['bwdp-pro-dis'] = __('Product Discount', 'your-text-domain');
     300            }
     301        }
     302        return $new_columns;
     303    }
     304   
     305    /**
     306     * Display content for custom column in the admin table.
     307     *
     308     * @param string $column_name Column name.
     309     * @param int $post_id Post ID.
     310     * @package Bulk_Woo_Discount
     311     * @since 1.0.0
     312     */
     313    public function bwdb_columns_discount_price($column_name, $post_id) {
     314        if ($column_name === 'bwdp-pro-dis') {
     315            $bwdp_dis_data = get_post_meta($post_id, 'bwdp-product-discount', true);
     316            if(!empty($bwdp_dis_data)){
     317                echo esc_html($bwdp_dis_data."%"); // Display custom data in the column
     318            }
     319            else{
     320                echo esc_html('—');
     321            }
     322        }
     323    }
     324   
     325    /**
    280326     * Adding Hooks
    281327     *
     
    300346
    301347        add_action( 'admin_notices', array( $this, 'bwdp_action_notices' ) );
     348       
     349        add_filter('manage_edit-product_columns', array( $this, 'bwdp_columns_head') );
     350
     351        add_action('manage_product_posts_custom_column', array( $this, 'bwdb_columns_discount_price'), 10, 2  );
     352
    302353    }
    303354}
  • bulk-woo-discount/trunk/bulk-woo-discount.php

    r3037139 r3072117  
    33 * Plugin Name:       Bulk Woo Discount
    44 * Description:       Woocommerce gives feature to provide discounted price.
    5  * Version:           1.0.0
     5 * Version:           1.1.0
    66 * Requires at least: 5.2
    77 * Requires PHP:      7.2
  • bulk-woo-discount/trunk/readme.txt

    r3036847 r3072117  
    44Requires at least: 5.4
    55Tested up to: 6.3
    6 Stable tag: 1.0.0
     6Stable tag: 1.1.0
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    51511. [Screenshot 1: Plugin settings page](screenshot-1.png)
    52522. [Screenshot 2: Bulk discount configuration](screenshot-2.png)
     533. [Screenshot 3: Remove product bulk discount](screenshot-3.png)
    5354
    5455== Upgrade Notice ==
Note: See TracChangeset for help on using the changeset viewer.