|
10 | 10 | * @since 1.0.0
|
11 | 11 | *
|
12 | 12 | * @wordpress-plugin
|
13 |
| - * Plugin Name: Customer Loyalty for WooCommerce® |
| 13 | + * Plugin Name: Loyalty & Rewards for WooCommerce® |
14 | 14 | * Plugin URI: https://www.deviodigital.com/customer-loyalty-for-woocommerce
|
15 | 15 | * Description: Increase customer loyalty by rewarding your customers for their repeat purchase behavior.
|
16 | 16 | * Version: 1.3.1
|
|
32 | 32 | */
|
33 | 33 | define( 'CUSTOMER_LOYALTY_VERSION', '1.3.1' );
|
34 | 34 |
|
| 35 | +/** |
| 36 | + * Create the CLWC Loyalty Log database table. |
| 37 | + * |
| 38 | + * This function creates a table for storing loyalty log entries in the database. |
| 39 | + * It includes fields for storing the customer ID, name, email, points, action details, and date. |
| 40 | + * |
| 41 | + * @package CLWC |
| 42 | + * @since 2.0.0 |
| 43 | + */ |
| 44 | +function clwc_create_loyalty_log_table() { |
| 45 | + global $wpdb; |
| 46 | + |
| 47 | + // Define table name with the WordPress table prefix. |
| 48 | + $table_name = $wpdb->prefix . 'clwc_loyalty_log'; |
| 49 | + |
| 50 | + // Set the database character set and collation for security. |
| 51 | + $charset_collate = $wpdb->get_charset_collate(); |
| 52 | + |
| 53 | + // SQL statement to create the table if it does not exist. |
| 54 | + $sql = "CREATE TABLE IF NOT EXISTS $table_name ( |
| 55 | + id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 56 | + user_id BIGINT(20) UNSIGNED NOT NULL, |
| 57 | + name VARCHAR(255) NOT NULL, |
| 58 | + email VARCHAR(255) NOT NULL, |
| 59 | + points INT(11) NOT NULL, |
| 60 | + details TEXT NOT NULL, |
| 61 | + date DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, |
| 62 | + PRIMARY KEY (id), |
| 63 | + KEY user_id (user_id), |
| 64 | + KEY date (date) |
| 65 | + ) $charset_collate;"; |
| 66 | + |
| 67 | + // Load the dbDelta function, which manages database upgrades and creation. |
| 68 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 69 | + dbDelta( $sql ); |
| 70 | +} |
| 71 | +register_activation_hook( __FILE__, 'clwc_create_loyalty_log_table' ); |
| 72 | + |
35 | 73 | /**
|
36 | 74 | * The code that runs during plugin activation.
|
37 | 75 | * This action is documented in includes/class-clwc-activator.php
|
|
0 commit comments