Changeset 3091857
- Timestamp:
- 05/24/2024 04:09:34 AM (20 months ago)
- Location:
- bw-coupon
- Files:
-
- 12 edited
- 1 copied
-
tags/1.4.3 (copied) (copied from bw-coupon/trunk)
-
tags/1.4.3/README.md (modified) (1 diff)
-
tags/1.4.3/bwc.php (modified) (1 diff)
-
tags/1.4.3/includes/coupons.php (modified) (5 diffs)
-
tags/1.4.3/includes/functions.php (modified) (1 diff)
-
tags/1.4.3/includes/mail.php (modified) (5 diffs)
-
tags/1.4.3/make_wp_readme.sh (modified) (1 diff)
-
trunk/README.md (modified) (1 diff)
-
trunk/bwc.php (modified) (1 diff)
-
trunk/includes/coupons.php (modified) (5 diffs)
-
trunk/includes/functions.php (modified) (1 diff)
-
trunk/includes/mail.php (modified) (5 diffs)
-
trunk/make_wp_readme.sh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
bw-coupon/tags/1.4.3/README.md
r2979375 r3091857 15 15 * curl_exec must be enabled for external image load 16 16 17 17 ### Example install in Debian 18 ```console 19 sudo apt-get install php8.2-xml php-font-lib php-dompdf-svg-lib php8.2-mbstring 20 ``` 18 21 ## Description 19 22 -
bw-coupon/tags/1.4.3/bwc.php
r2979608 r3091857 4 4 * Description: This plugin lets WooCommerce customers purchase coupons as PDF ( Portable Document Format). You design the PDF with the WordPress Product HTML Editor. The Coupons are automatically generated and delivered to customers as PDF attachments 5 5 * Depends: WooCommerce 6 * Version: 1.4. 27 * Requires PHP: 7.16 * Version: 1.4.3 7 * Requires PHP: 8.0 8 8 * Author: Myridia.com Co., LTD. 9 * Author URI: http ://bw-coupon.myridia.com/9 * Author URI: https://myridia.com/bw-coupon 10 10 * Developer: Myridia.com Co., LTD. 11 11 * Text Domain: bw-coupon 12 12 * Domain Path: /languages 13 * WC requires at least: 2.214 * WC tested up to: 8. 1.115 * WP requires at least: 5.0.016 * WP tested up to: 6. 3.113 * WC requires at least: 8.9.1 14 * WC tested up to: 8.9.1 15 * WP requires at least: 6.5.2 16 * WP tested up to: 6.5.2 17 17 * License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 18 18 * -
bw-coupon/tags/1.4.3/includes/coupons.php
r2979375 r3091857 150 150 { 151 151 global $wpdb; 152 152 bwc_logging( '...bwc_register_coupons fnc'); 153 153 if ( !$wpdb ): 154 154 return false; … … 156 156 157 157 $generated_coupon = 0; 158 158 $emails_to_send = []; 159 159 foreach ( $post_ids as $post_id ): 160 160 $coupons = bwc_check_order_coupons_count( $post_id ); /* General check if coupon order exist */ 161 161 if ( $coupons['count'] > 0 ): 162 bwc_logging( '...coupons count: ' . $coupons['count']); 162 163 $order = new WC_Order( $post_id ); 163 164 $items = $order->get_items(); … … 179 180 180 181 if( bwc_coupon_fulfilled($post_id,$key,$item['qty']) == FALSE): 181 182 183 bwc_logging("...create coupon product id: " .$product_id . " post id:" . $post_id ." key: " .$key ); 182 184 $coupon_id = bwc_create_woocommerce_coupon( $product_id, $post_id, $key); 183 185 … … 196 198 ); 197 199 198 bwc_send_email( $coupon_id );200 $emails_to_send[] = $coupon_id; //add coupon ids for sending 199 201 endif; 200 202 endif; 201 202 203 endfor; 203 204 endif; … … 206 207 endif; 207 208 endforeach;; 209 210 bwc_send_emails( $emails_to_send ); 211 // var_dump($emails_to_send); 208 212 return $generated_coupon; 209 213 } -
bw-coupon/tags/1.4.3/includes/functions.php
r2979375 r3091857 455 455 456 456 /** 457 * Helper Loggin function 458 * 459 * @param string 460 */ 461 function bwc_logging( $str, $type='info' ) 462 { 463 $logger = wc_get_logger(); 464 $context = array( 'source' => 'bwc' ); 465 $logger->info( $str, $context ); 466 } 467 468 469 /** 457 470 * Helper function to create de query arguments of the URL. 458 471 * -
bw-coupon/tags/1.4.3/includes/mail.php
r2979375 r3091857 14 14 } 15 15 16 function bwc_send_test_email( $mailto=FALSE, $customer=FALSE, $title=False, $order_id='' ) 16 17 function bwc_send_emails( $coupon_ids ) 17 18 { 18 load_plugin_textdomain( 'bw-coupon', false, 'bw-coupon/languages' ); 19 if( $mailto ): 20 $subject = ! empty( get_option( 'bwc_subject' ) ) ? get_option( 'bwc_subject' ) : __('Coupon','bw-coupon'); 21 $message = ! empty( get_option( 'bwc_email_message' ) ) ? get_option( 'bwc_email_message' ) : ''; 22 $mail_settings = ! empty( get_option( 'woocommerce_email_from_address' ) ) ? get_option( 'woocommerce_email_from_address' ) : get_bloginfo( 'admin_email' ); 23 $from_settings = ! empty( get_option( 'woocommerce_email_from_name' ) ) ? get_option( 'woocommerce_email_from_name' ) : get_bloginfo( 'name' ); 24 $headers = 'MIME-Version: 1.0' . "\r\n"; 25 $headers .= "Content-Type: text/html\n"; 26 $headers .= 'From: ' . $from_settings . ' <' . $mail_settings . '>' . "\r\n" . 'Reply-To: ' . $mail_settings . '' . "\r\n"; 27 $message = bwc_email_format($message, $customer, $title, $order_id); 28 $cc = ! empty( get_option( 'bwc_cc_mail' ) ) ? get_option( 'bwc_cc_mail' ) : FALSE; 29 $bcc = ! empty( get_option( 'bwc_bcc_mail' ) ) ? get_option( 'bwc_bcc_mail' ) : FALSE; 30 31 if($bcc): 32 $headers .= 'Bcc: '. $bcc . "\r\n"; 33 endif; 34 35 if($cc): 36 $headers .= 'Cc: '. $cc . "\r\n"; 37 endif; 38 39 $r = wp_mail( $mailto , $subject, $message, $headers); 40 return $r; 41 endif; 19 bwc_logging('...bwc_send_emails fn'); 20 foreach( $coupon_ids as $k => $i ): 21 bwc_logging( '...send email pdf to ' . $i); 22 $r = bwc_send_email($i); //enable later 23 endforeach; 42 24 } 43 25 … … 45 27 function bwc_send_email( $coupon_id, $mailto=FALSE ) 46 28 { 29 47 30 load_plugin_textdomain( 'bw-coupon', false, 'bw-coupon/languages' ); 48 31 $coupon = bwc_get_coupon( $coupon_id ); 49 32 $order = new WC_Order( $coupon->id_order ); 50 33 $title = get_post_meta( $coupon->id_order , '_billing_title', true ); 51 34 52 35 53 36 $coupon_post = get_post( $coupon_id ); … … 63 46 64 47 $r = FALSE; 48 65 49 if( $mailto ): 50 //var_dump("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); 51 //var_dump($coupon_id ); 52 //var_dump("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); 66 53 $pdf = bwc_create_pdf( $coupon_id ); 54 67 55 $_path = tempnam(sys_get_temp_dir(), __('Coupon','bw-coupon'). "_{$coupon_code}__"); 68 56 rename($_path, $_path .= '.pdf'); 69 57 file_put_contents( $_path, $pdf ); 58 70 59 $subject = ! empty( get_option( 'bwc_subject' ) ) ? get_option( 'bwc_subject' ) : __('Coupon','bw-coupon'); 71 60 $message = ! empty( get_option( 'bwc_email_message' ) ) ? get_option( 'bwc_email_message' ) : __( 'Please download the PDF', "bw-coupon" ); … … 97 86 return FALSE; 98 87 endif; 88 99 89 endif; 90 100 91 return FALSE; 101 92 } … … 132 123 133 124 125 function bwc_send_test_email( $mailto=FALSE, $customer=FALSE, $title=False, $order_id='' ) 126 { 127 load_plugin_textdomain( 'bw-coupon', false, 'bw-coupon/languages' ); 128 if( $mailto ): 129 $subject = ! empty( get_option( 'bwc_subject' ) ) ? get_option( 'bwc_subject' ) : __('Coupon','bw-coupon'); 130 $message = ! empty( get_option( 'bwc_email_message' ) ) ? get_option( 'bwc_email_message' ) : ''; 131 $mail_settings = ! empty( get_option( 'woocommerce_email_from_address' ) ) ? get_option( 'woocommerce_email_from_address' ) : get_bloginfo( 'admin_email' ); 132 $from_settings = ! empty( get_option( 'woocommerce_email_from_name' ) ) ? get_option( 'woocommerce_email_from_name' ) : get_bloginfo( 'name' ); 133 $headers = 'MIME-Version: 1.0' . "\r\n"; 134 $headers .= "Content-Type: text/html\n"; 135 $headers .= 'From: ' . $from_settings . ' <' . $mail_settings . '>' . "\r\n" . 'Reply-To: ' . $mail_settings . '' . "\r\n"; 136 $message = bwc_email_format($message, $customer, $title, $order_id); 137 $cc = ! empty( get_option( 'bwc_cc_mail' ) ) ? get_option( 'bwc_cc_mail' ) : FALSE; 138 $bcc = ! empty( get_option( 'bwc_bcc_mail' ) ) ? get_option( 'bwc_bcc_mail' ) : FALSE; 139 140 if($bcc): 141 $headers .= 'Bcc: '. $bcc . "\r\n"; 142 endif; 143 144 if($cc): 145 $headers .= 'Cc: '. $cc . "\r\n"; 146 endif; 147 148 $r = wp_mail( $mailto , $subject, $message, $headers); 149 return $r; 150 endif; 151 } -
bw-coupon/tags/1.4.3/make_wp_readme.sh
r2979375 r3091857 1 1 #!/bin/bash 2 2 3 wget -q https://raw.githubusercontent.com/fumikito/wp-readme/master/wp-readme.php -O wp-readme.php 3 docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php: 8.2-cli php wp-readme.php4 docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.4-cli php wp-readme.php 4 5 rm wp-readme.php -
bw-coupon/trunk/README.md
r2979375 r3091857 15 15 * curl_exec must be enabled for external image load 16 16 17 17 ### Example install in Debian 18 ```console 19 sudo apt-get install php8.2-xml php-font-lib php-dompdf-svg-lib php8.2-mbstring 20 ``` 18 21 ## Description 19 22 -
bw-coupon/trunk/bwc.php
r2979608 r3091857 4 4 * Description: This plugin lets WooCommerce customers purchase coupons as PDF ( Portable Document Format). You design the PDF with the WordPress Product HTML Editor. The Coupons are automatically generated and delivered to customers as PDF attachments 5 5 * Depends: WooCommerce 6 * Version: 1.4. 27 * Requires PHP: 7.16 * Version: 1.4.3 7 * Requires PHP: 8.0 8 8 * Author: Myridia.com Co., LTD. 9 * Author URI: http ://bw-coupon.myridia.com/9 * Author URI: https://myridia.com/bw-coupon 10 10 * Developer: Myridia.com Co., LTD. 11 11 * Text Domain: bw-coupon 12 12 * Domain Path: /languages 13 * WC requires at least: 2.214 * WC tested up to: 8. 1.115 * WP requires at least: 5.0.016 * WP tested up to: 6. 3.113 * WC requires at least: 8.9.1 14 * WC tested up to: 8.9.1 15 * WP requires at least: 6.5.2 16 * WP tested up to: 6.5.2 17 17 * License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 18 18 * -
bw-coupon/trunk/includes/coupons.php
r2979375 r3091857 150 150 { 151 151 global $wpdb; 152 152 bwc_logging( '...bwc_register_coupons fnc'); 153 153 if ( !$wpdb ): 154 154 return false; … … 156 156 157 157 $generated_coupon = 0; 158 158 $emails_to_send = []; 159 159 foreach ( $post_ids as $post_id ): 160 160 $coupons = bwc_check_order_coupons_count( $post_id ); /* General check if coupon order exist */ 161 161 if ( $coupons['count'] > 0 ): 162 bwc_logging( '...coupons count: ' . $coupons['count']); 162 163 $order = new WC_Order( $post_id ); 163 164 $items = $order->get_items(); … … 179 180 180 181 if( bwc_coupon_fulfilled($post_id,$key,$item['qty']) == FALSE): 181 182 183 bwc_logging("...create coupon product id: " .$product_id . " post id:" . $post_id ." key: " .$key ); 182 184 $coupon_id = bwc_create_woocommerce_coupon( $product_id, $post_id, $key); 183 185 … … 196 198 ); 197 199 198 bwc_send_email( $coupon_id );200 $emails_to_send[] = $coupon_id; //add coupon ids for sending 199 201 endif; 200 202 endif; 201 202 203 endfor; 203 204 endif; … … 206 207 endif; 207 208 endforeach;; 209 210 bwc_send_emails( $emails_to_send ); 211 // var_dump($emails_to_send); 208 212 return $generated_coupon; 209 213 } -
bw-coupon/trunk/includes/functions.php
r2979375 r3091857 455 455 456 456 /** 457 * Helper Loggin function 458 * 459 * @param string 460 */ 461 function bwc_logging( $str, $type='info' ) 462 { 463 $logger = wc_get_logger(); 464 $context = array( 'source' => 'bwc' ); 465 $logger->info( $str, $context ); 466 } 467 468 469 /** 457 470 * Helper function to create de query arguments of the URL. 458 471 * -
bw-coupon/trunk/includes/mail.php
r2979375 r3091857 14 14 } 15 15 16 function bwc_send_test_email( $mailto=FALSE, $customer=FALSE, $title=False, $order_id='' ) 16 17 function bwc_send_emails( $coupon_ids ) 17 18 { 18 load_plugin_textdomain( 'bw-coupon', false, 'bw-coupon/languages' ); 19 if( $mailto ): 20 $subject = ! empty( get_option( 'bwc_subject' ) ) ? get_option( 'bwc_subject' ) : __('Coupon','bw-coupon'); 21 $message = ! empty( get_option( 'bwc_email_message' ) ) ? get_option( 'bwc_email_message' ) : ''; 22 $mail_settings = ! empty( get_option( 'woocommerce_email_from_address' ) ) ? get_option( 'woocommerce_email_from_address' ) : get_bloginfo( 'admin_email' ); 23 $from_settings = ! empty( get_option( 'woocommerce_email_from_name' ) ) ? get_option( 'woocommerce_email_from_name' ) : get_bloginfo( 'name' ); 24 $headers = 'MIME-Version: 1.0' . "\r\n"; 25 $headers .= "Content-Type: text/html\n"; 26 $headers .= 'From: ' . $from_settings . ' <' . $mail_settings . '>' . "\r\n" . 'Reply-To: ' . $mail_settings . '' . "\r\n"; 27 $message = bwc_email_format($message, $customer, $title, $order_id); 28 $cc = ! empty( get_option( 'bwc_cc_mail' ) ) ? get_option( 'bwc_cc_mail' ) : FALSE; 29 $bcc = ! empty( get_option( 'bwc_bcc_mail' ) ) ? get_option( 'bwc_bcc_mail' ) : FALSE; 30 31 if($bcc): 32 $headers .= 'Bcc: '. $bcc . "\r\n"; 33 endif; 34 35 if($cc): 36 $headers .= 'Cc: '. $cc . "\r\n"; 37 endif; 38 39 $r = wp_mail( $mailto , $subject, $message, $headers); 40 return $r; 41 endif; 19 bwc_logging('...bwc_send_emails fn'); 20 foreach( $coupon_ids as $k => $i ): 21 bwc_logging( '...send email pdf to ' . $i); 22 $r = bwc_send_email($i); //enable later 23 endforeach; 42 24 } 43 25 … … 45 27 function bwc_send_email( $coupon_id, $mailto=FALSE ) 46 28 { 29 47 30 load_plugin_textdomain( 'bw-coupon', false, 'bw-coupon/languages' ); 48 31 $coupon = bwc_get_coupon( $coupon_id ); 49 32 $order = new WC_Order( $coupon->id_order ); 50 33 $title = get_post_meta( $coupon->id_order , '_billing_title', true ); 51 34 52 35 53 36 $coupon_post = get_post( $coupon_id ); … … 63 46 64 47 $r = FALSE; 48 65 49 if( $mailto ): 50 //var_dump("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); 51 //var_dump($coupon_id ); 52 //var_dump("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); 66 53 $pdf = bwc_create_pdf( $coupon_id ); 54 67 55 $_path = tempnam(sys_get_temp_dir(), __('Coupon','bw-coupon'). "_{$coupon_code}__"); 68 56 rename($_path, $_path .= '.pdf'); 69 57 file_put_contents( $_path, $pdf ); 58 70 59 $subject = ! empty( get_option( 'bwc_subject' ) ) ? get_option( 'bwc_subject' ) : __('Coupon','bw-coupon'); 71 60 $message = ! empty( get_option( 'bwc_email_message' ) ) ? get_option( 'bwc_email_message' ) : __( 'Please download the PDF', "bw-coupon" ); … … 97 86 return FALSE; 98 87 endif; 88 99 89 endif; 90 100 91 return FALSE; 101 92 } … … 132 123 133 124 125 function bwc_send_test_email( $mailto=FALSE, $customer=FALSE, $title=False, $order_id='' ) 126 { 127 load_plugin_textdomain( 'bw-coupon', false, 'bw-coupon/languages' ); 128 if( $mailto ): 129 $subject = ! empty( get_option( 'bwc_subject' ) ) ? get_option( 'bwc_subject' ) : __('Coupon','bw-coupon'); 130 $message = ! empty( get_option( 'bwc_email_message' ) ) ? get_option( 'bwc_email_message' ) : ''; 131 $mail_settings = ! empty( get_option( 'woocommerce_email_from_address' ) ) ? get_option( 'woocommerce_email_from_address' ) : get_bloginfo( 'admin_email' ); 132 $from_settings = ! empty( get_option( 'woocommerce_email_from_name' ) ) ? get_option( 'woocommerce_email_from_name' ) : get_bloginfo( 'name' ); 133 $headers = 'MIME-Version: 1.0' . "\r\n"; 134 $headers .= "Content-Type: text/html\n"; 135 $headers .= 'From: ' . $from_settings . ' <' . $mail_settings . '>' . "\r\n" . 'Reply-To: ' . $mail_settings . '' . "\r\n"; 136 $message = bwc_email_format($message, $customer, $title, $order_id); 137 $cc = ! empty( get_option( 'bwc_cc_mail' ) ) ? get_option( 'bwc_cc_mail' ) : FALSE; 138 $bcc = ! empty( get_option( 'bwc_bcc_mail' ) ) ? get_option( 'bwc_bcc_mail' ) : FALSE; 139 140 if($bcc): 141 $headers .= 'Bcc: '. $bcc . "\r\n"; 142 endif; 143 144 if($cc): 145 $headers .= 'Cc: '. $cc . "\r\n"; 146 endif; 147 148 $r = wp_mail( $mailto , $subject, $message, $headers); 149 return $r; 150 endif; 151 } -
bw-coupon/trunk/make_wp_readme.sh
r2979375 r3091857 1 1 #!/bin/bash 2 2 3 wget -q https://raw.githubusercontent.com/fumikito/wp-readme/master/wp-readme.php -O wp-readme.php 3 docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php: 8.2-cli php wp-readme.php4 docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.4-cli php wp-readme.php 4 5 rm wp-readme.php
Note: See TracChangeset
for help on using the changeset viewer.