Changeset 2534598
- Timestamp:
- 05/20/2021 06:15:32 AM (3 years ago)
- Location:
- vmi-direct-checkout
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
vmi-direct-checkout/tags/readme.txt
r2501738 r2534598 6 6 Tested up to: 5.6 7 7 Requires PHP: 7.3 8 Stable tag: 2.0.08 Stable tag: .0.0 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
vmi-direct-checkout/trunk/assets/css/style.css
r2486573 r2534598 3 3 .inner-panel-dash-vmi 4 4 { 5 padding: 40px;5 padding:40px; 6 6 background: white !important; 7 7 max-width: 400px; … … 23 23 input.submit-plugin-btn 24 24 { 25 font-size: 20px;25 font-size: px; 26 26 max-width: 400px; 27 height: 4 5px;28 border-radius: 5px;27 height: 4px; 28 border-radius: px; 29 29 color: white; 30 30 text-transform: uppercase; … … 35 35 transition: 0.5s all; 36 36 width: 100%; 37 37 38 } 38 39 input.submit-plugin-btn:hover … … 97 98 } 98 99 /*ADMIN TOGGLE BUTTON CSS*/ 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 99 166 </style> -
vmi-direct-checkout/trunk/readme.txt
r2501738 r2534598 6 6 Tested up to: 5.6 7 7 Requires PHP: 7.3 8 Stable tag: 2. 0.08 Stable tag: 2. 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
vmi-direct-checkout/trunk/wc-direct-checkout-vmi.php
r2486553 r2534598 7 7 Plugin URI: https://vibrantmediainc.com/ 8 8 Description: This plugin is used for adding a <strong> Buy Now</strong> button in Product page & Proceed to checkout directly. 9 Version: 2.0.09 Version: .0.0 10 10 Author: Vibrant Media Inc. 11 11 Author URI: https://vibrantmediainc.com/ … … 20 20 function admin_CSS_JS_File() { 21 21 22 /*STYLE FILE INCLUDE CODE*/ 22 23 23 define( 'MY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); 24 24 include( MY_PLUGIN_PATH . 'assets/css/style.css'); 25 25 26 //define( 'MY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); 26 27 27 include( MY_PLUGIN_PATH . 'assets/js/script.js'); 28 /*STYLE FILE INCLUDE CODE*/ 29 30 } 31 // FILE ADD FOR ADMIN 32 33 34 // Table genration Code 28 29 30 } 35 31 36 32 function vmi_create_table(){ 37 38 global $wpdb;39 40 33 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 41 42 $ table_name = $wpdb->prefix . "dirctcheckoutvmi";43 44 if ( count( $wpdb->get_var( 'SHOW TABLES LIKE $table_name' )) == 0 ){ 45 46 $sql_query_to_create_table = "CREATE TABLE IF NOT EXISTS $table_name ( 47 `id` int(11) NOT NULL AUTO_INCREMENT,48 `buttontext` varchar(150) NOT NULL, 49 `bgcolor` varchar(150) NOT NULL, 50 `textcolor` varchar(150) NOT NULL, 51 `cartHide` varchar(1) NOT NULL,52 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 53 PRIMARY KEY (`id`) 54 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci"; 55 56 dbDelta($sql_query_to_create_table); 57 58 $wpdb->insert($table_name, array( 59 'buttontext' => 'Buy Now',60 'bgcolor' => '#cccccc', 61 'textcolor' => '#000000', 62 'cartHide' => '0', 63 ));64 65 66 } 34 $default_value_buttontext = 'Buy Now'; 35 $ 36 $default_value_textcolor = '#000000'; 37 $default_value_cartHide = 0; 38 $dirctcheckoutvmi_buybtn = 0; 39 if (FALSE === get_option('dirctcheckoutvmi_buttontext') && FALSE === update_option('dirctcheckoutvmi_buttontext',FALSE)){ 40 41 } 42 43 if (FALSE === get_option('dirctcheckoutvmi_bgcolor') && FALSE === update_option('dirctcheckoutvmi_bgcolor',FALSE)){ 44 45 } 46 47 if (FALSE === get_option('dirctcheckoutvmi_textcolor') && FALSE === update_option('dirctcheckoutvmi_textcolor',FALSE)){ 48 add_option('dirctcheckoutvmi_textcolor',$default_value_textcolor); 49 } 50 51 if (FALSE === get_option('dirctcheckoutvmi_cartHide') && FALSE === update_option('dirctcheckoutvmi_cartHide',FALSE)){ 52 53 } 54 55 if (FALSE === get_option('dirctcheckoutvmi_buybtn') && FALSE === update_option('dirctcheckoutvmi_buybtn',FALSE)){ 56 ); 57 } 58 59 67 60 68 61 } 69 62 register_activation_hook(__FILE__, 'vmi_create_table'); 70 63 71 72 73 74 /*AFTER ACTIVATING THE PLUGIN REDIREXT TO PLUGIN PAGE IN ADMIN DASHBOARD*/75 64 register_activation_hook(__FILE__, 'my_plugin_activate'); 76 65 add_action('admin_init', 'my_plugin_redirect'); … … 86 75 } 87 76 } 88 /*AFTER ACTIVATING THE PLUGIN REDIREXT TO PLUGIN PAGE IN ADMIN DASHBOARD*/ 89 90 91 92 add_action( 'woocommerce_after_add_to_cart_button', 'vmi_add_custom_addtocart_and_checkout' ); 93 function vmi_add_custom_addtocart_and_checkout() { 94 global $product; 95 96 97 98 99 100 101 $addtocart_url = wc_get_checkout_url().'?add-to-cart='.$product->get_id(); 102 $button_class = 'vmi_single_add_to_cart_button vmi_button vmi_alt vmi_custom-checkout-btn'; 103 104 global $wpdb; 105 106 // $q="SELECT * FROM wp_dirctcheckoutvmi"; 107 // $uid="12"; 108 // $pid ="3"; 109 110 // $results = $wpdb->get_results( "SELECT `buttontext` FROM `wp_dirctcheckoutvmi`"); // Query to fetch data from database table and storing in $results 111 112 $table_name = $wpdb->prefix . "dirctcheckoutvmi"; 113 114 115 $results = $wpdb->get_results( "SELECT * FROM $table_name" ); 116 if(!empty($results)) // Checking if $results have some values or not 117 { 118 // $butbuynow = "this is text"; 119 foreach($results as $row){ 120 121 $butbuynow = $row->buttontext; 122 $bgcolors = $row->bgcolor; 123 $txtcolors = $row->textcolor; 124 $button_text = __($butbuynow, "woocommerce"); 125 $carthide = $row->cartHide; 126 } 127 128 } 129 130 131 132 if( $product->is_type( 'simple' )) : 133 ?> 134 135 <style> 136 .vmi_custom-checkout-btn 77 78 function woocommerce_template_single_buynow() 137 79 { 138 padding: 10px 40px; 139 color: <?php echo $txtcolors ?>; 140 background-color: <?php echo $bgcolors ?>; 141 border-radius:50px; 142 font-weight:bold; 143 text-transform:uppercase; 144 letter-spacing:1px; 145 display: inline-block; 146 } 147 .vmi_custom-checkout-btn:hover 148 { 149 color: <?php echo $bgcolors ?>; 150 background-color: <?php echo $txtcolors ?>; 151 } 152 153 <?php 154 if ( $carthide == 1) { 155 ?> 156 157 .woocommerce div.product form.cart .button.single_add_to_cart_button{ 158 display:none; 159 } 160 161 <?php 162 163 } ?> 164 165 </style> 166 <script> 167 jQuery(function($) { 168 var url = '<?php echo $addtocart_url; ?>', 169 qty = 'input.qty', 170 button = 'a.custom-checkout-btn'; 171 172 // On input/change quantity event 173 $(qty).on('input change', function() { 174 $(button).attr('href', url + '&quantity=' + $(this).val() ); 175 }); 176 177 if(<?php echo $carthide ?> == '1'){ 178 179 jQuery('.woocommerce div.product form.cart .button.single_add_to_cart_button').remove(); 180 } 181 182 }); 183 </script> 184 <?php 185 186 elseif( $product->is_type( 'variable' ) ) : 187 188 $addtocart_url = wc_get_checkout_url().'?add-to-cart='; 189 ?> 190 <script> 191 jQuery(function($) { 192 var url = '<?php echo $addtocart_url; ?>', 193 vid = 'input[name="variation_id"]', 194 pid = 'input[name="product_id"]', 195 qty = 'input.qty', 196 button = 'a.custom-checkout-btn'; 197 198 // Once DOM is loaded 199 setTimeout( function(){ 200 if( $(vid).val() != '' ){ 201 $(button).attr('href', url + $(vid).val() + '&quantity=' + $(qty).val() ); 202 } 203 }, 300 ); 204 205 // On input/change quantity event 206 $(qty).on('input change', function() { 207 if( $(vid).val() != '' ){ 208 $(button).attr('href', url + $(vid).val() + '&quantity=' + $(this).val() ); 209 } 210 }); 211 212 // On select attribute field change event 213 $('.variations_form').on('change blur', 'table.variations select', function() { 214 if( $(vid).val() != '' ){ 215 $(button).attr('href', url + $(vid).val() + '&quantity=' + $(qty).val() ); 216 } 217 }); 218 }); 219 </script> 220 <?php 221 endif; 222 echo '<a href="'.$addtocart_url.'" class="'.$button_class.'">'.$button_text.'</a>'; ?> 223 224 <?php 225 226 227 // $checboxaddtocart = $_POST['cartHide'] ; 228 // if ($_POST["Submit" ]=="Submit") 229 // { 230 // for ($i=0; $i<sizeof ($checboxaddtocart);$i++) { 231 // $query="INSERT INTO $table_name (name) VALUES ('".$checboxaddtocart[$i]. "')"; 232 // mysql_query($query) or die(mysql_error()); 233 // } 234 // echo "Record is inserted"; 235 // } 236 237 238 } 239 240 241 242 /*CUSTOM MENU CODE*/ 80 global $product; 81 $buttontext = get_option('dirctcheckoutvmi_buttontext'); 82 $bgcolor = get_option('dirctcheckoutvmi_bgcolor'); 83 $textcolor = get_option('dirctcheckoutvmi_textcolor'); 84 $addtocart_url = wc_get_checkout_url().'?add-to-cart='.$product->get_id(); 85 $button_class = 'vmi_single_add_to_cart_button vmi_button vmi_alt vmi_custom-checkout-btn'; 86 $html = '<a href="'.$addtocart_url.'" id="vmiDirectCheckoutBtn" class="'.$button_class.'">'.$buttontext.'</a> <style> 87 .vmi_custom-checkout-btn 88 { 89 padding: 10px 40px; 90 color:'.$textcolor.'; 91 background-color: '.$bgcolor.'; 92 border-radius:50px; 93 font-weight:bold; 94 text-transform:uppercase; 95 letter-spacing:1px; 96 display: inline-block; 97 } 98 .vmi_custom-checkout-btn:hover 99 { 100 color:'.$bgcolor.'; 101 background-color:'.$textcolor.'; 102 } 103 104 105 <style>'; 106 echo $html; 107 } 108 add_action( 'init', 'dirctcheckoutvmi_setup_pro' ); 109 function dirctcheckoutvmi_setup_pro() { 110 $cartHide = get_option('dirctcheckoutvmi_cartHide'); 111 $buybtn = get_option('dirctcheckoutvmi_buybtn'); 112 if($cartHide == 1){ remove_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart',30); } 113 if($buybtn == 0){ add_action('woocommerce_single_product_summary','woocommerce_template_single_buynow',30); } 114 } 243 115 244 116 function my_admin_menu() { 245 246 117 add_menu_page( 247 118 … … 263 134 } 264 135 265 266 267 136 add_action( 'admin_menu', 'my_admin_menu' ); 268 137 269 //include plugin_dir_path( __FILE__ ) . 'setting/admin-setting.php';270 271 138 function my_admin_page_contents() { 272 273 ?> 274 275 276 <h1> 277 <?php esc_html_e( 'Buy Now Woocommerce', 'my-plugin-textdomain' ); ?> 278 </h1> 279 280 281 <?php 282 283 284 285 global $wpdb; 286 287 $table_name = $wpdb->prefix . "dirctcheckoutvmi"; 288 289 290 $results = $wpdb->get_results( "SELECT * FROM $table_name ORDER BY ID DESC LIMIT 1" ); 291 if(!empty($results)) // Checking if $results have some values or not 292 { 293 294 foreach($results as $row){ 295 296 297 $inputtext = $row->buttontext; 298 $bgcolors = $row->bgcolor; 299 $txtcolors = $row->textcolor; 300 $carthide = $row->cartHide; 301 302 ?> 303 <div class="notice notice-warning is-dismissible" style="margin:0px;max-width: 430px;"> 139 if( isset($_POST['submit']) ){ 140 $cusbuttontext = $_POST["cusbuttontext"]; 141 $bgcolors = $_POST["bgcolors"]; 142 $textcolors = $_POST["textcolors"]; 143 update_option('dirctcheckoutvmi_buttontext',$cusbuttontext); 144 update_option('dirctcheckoutvmi_bgcolor',$bgcolors); 145 update_option('dirctcheckoutvmi_textcolor',$textcolors); 146 147 148 if(isset($_POST['cartHide']) && $_POST['cartHide'] == '0'){ 149 update_option('dirctcheckoutvmi_cartHide',1); 150 } 151 else{ 152 update_option('dirctcheckoutvmi_cartHide',0); 153 } 154 if(isset($_POST['buybtn']) && $_POST['buybtn'] == '0'){ 155 update_option('dirctcheckoutvmi_buybtn',1); 156 } 157 else{ 158 update_option('dirctcheckoutvmi_buybtn',0); 159 } 160 //if(isset($_POST['buybtn'])){update_option('dirctcheckoutvmi_buybtn',$_POST['buybtn']);} 161 162 } 163 $buttontext = get_option('dirctcheckoutvmi_buttontext'); 164 $bgcolor = get_option('dirctcheckoutvmi_bgcolor'); 165 $textcolor = get_option('dirctcheckoutvmi_textcolor'); 166 $cartHide = get_option('dirctcheckoutvmi_cartHide'); 167 //$atcbtn = get_option('dirctcheckoutvmi_cartHide'); 168 $buybtn = get_option('dirctcheckoutvmi_buybtn'); 169 //$byubtn = get_option('dirctcheckoutvmi_buybtn'); 170 //if ( $cartHide == 1) {$checked = "checked"; $atcbtn = 0; } else { $atcbtn = 1; } 171 //if ( $buybtn == 1) {$buybtn_checked = "checked"; $byubtn = 0; } else { $byubtn = 1; } 172 173 if( $cartHide == 1) { 174 $cartCheck = "checked"; 175 } 176 if( $buybtn == 1) { 177 $buyCheck = "checked"; 178 } 179 180 $admin_html = '<h1>Buy Now Woocommerce</h1><div class="notice notice-warning is-dismissible" style="margin:0px;max-width: 430px;"> 304 181 <p>Give us a 5 Stars Review <a href="https://wordpress.org/support/plugin/vmi-direct-checkout/reviews/#new-post" target="_blank">Give Review</a></p> 305 182 </div> … … 308 185 <form action="" method="post"> 309 186 310 <label for="cartHide" class="nametext-plugin">Hide Add to Cart Button</label> 311 <br> 312 <br> 313 <label class="switch"> 314 <input type="checkbox" name="cartHide" value="0" <?php if ( $carthide == 1) {echo "checked";} ?> > 315 <span class="slider round"></span> 316 </label> 317 318 <br> 319 <br> 320 <label class="nametext-plugin">Button Text</label> 321 <br> 322 <br> 323 <input type="text" class="input-plugin" name="cusbuttontext" required="required" value="<?php echo $inputtext ?>"> 324 325 <br> 326 <br> 327 <br> 187 <div class="inner-container"> 188 <label for="cartHide" class="nametext-plugin">Hide Add to Cart Button</label> 189 <label class="switch"> 190 <input type="checkbox" name="cartHide" value="0" '.$cartCheck.'> 191 <span class="slider round"></span> 192 </label> 193 </div> 194 195 <div class="inner-container"> 196 <label for="buybtn" class="nametext-plugin">Hide Buy Now Button</label> 197 <label class="switch"> 198 <input type="checkbox" name="buybtn" value="0" '.$buyCheck.'> 199 <span class="slider round"></span> 200 </label> 201 </div> 202 203 <div class="inner-container"> 328 204 <label for="bgcolor" class="nametext-plugin">Background Color</label> 329 < br>330 < br>331 < input type="color" id="bgcolors" class="input-plugin" name="bgcolors" value="<?php echo $bgcolors ?>" style="width: 235px;height: 40px;vertical-align: middle;">332 <br>333 <br> 334 <br>205 <> 206 <> 207 <> 208 > 209 210 > 335 211 <label for="txtcolor" class="nametext-plugin">Text Color</label> 336 <br> 337 <br> 338 <input type="color" class="input-plugin" id="txtcolors" name="textcolors" value="<?php echo $txtcolors ?>" style="width: 235px;height: 40px;vertical-align: middle;"> 339 <br> 340 <br> 341 <br> 342 <input type="submit" class="submit-plugin-btn" value="Save" name="submit"/> 343 <br> 344 <hr> 345 <br> 212 <div class="input-color-container"> 213 <input type="color" class="input-plugin input-color" id="txtcolors" name="textcolors" value="'.$textcolor.'"> 214 </div> 215 </div> 216 217 <div class="inner-container input-btn-text-container"> 218 <label class="nametext-plugin">Enter Your Text Here </label> 219 <input type="text" class="input-plugin" name="cusbuttontext" required="required" value="'.$buttontext.'" placeholder="Buy Now"> 220 </div> 221 222 <input type="submit" class="submit-plugin-btn" value="Update" name="submit"/> 223 224 <p class="vmi-checkout-suggestion">Buy now button styling use this ID <input disabled="" value="#vmiDirectCheckoutBtn"> </p> 346 225 </form> 347 226 </div> 348 349 <img src=" <?php echo plugin_dir_url( __FILE__ ) ?>assets/icon-256x256.png" width="80px">227 <br> 228 <img src="0px"> 350 229 <br> 351 <a href="https://wordpress.org/support/plugin/vmi-direct-checkout/reviews/#new-post" target="_blank">Give us a 5 Stars Review</a> 352 353 <?php 354 } 355 356 } 357 358 ?> 359 360 361 <?php 362 363 } 364 365 366 367 368 369 370 //$cusbuttontext = $_POST['cusbuttontext']; 371 372 373 if( isset($_POST['submit']) ){ 374 375 $cusbuttontext = $_POST["cusbuttontext"]; 376 $bgcolors = $_POST["bgcolors"]; 377 $textcolors = $_POST["textcolors"]; 378 379 380 381 382 $cartItemValue = "0"; 383 if( array_key_exists( 'cartHide', $_POST ) && $_POST['cartHide'] == '0' ){ 384 $cartItemValue = "1"; 385 } 386 //$cartHide = $_POST["cartHide"]; 387 $table_name = $wpdb->prefix . "dirctcheckoutvmi"; 388 $wpdb->insert($table_name, array( 389 'buttontext' => $cusbuttontext, 390 'bgcolor' => $bgcolors, 391 'textcolor' => $textcolors, 392 'cartHide' => $cartItemValue, 393 )); 394 395 396 397 398 399 } 400 ?> 401 402 403 <?php 404 /* 405 add_action('wp_head','thwmscf_hide_next_button'); 406 function thwmscf_hide_next_button(){ 407 if(is_checkout(true)){ 408 $have_category = false; 409 410 foreach ( WC()->cart->get_cart() as $item_key => $item_value ){ 411 $_product = $item_value['data']; 412 $product_id = $_product->get_id(); 413 414 if(has_term( 'category_name', 'product_cat', $product_id)){ 415 $have_category = true; 416 } 417 } 418 419 if(!$have_category){ 420 ?> 421 <style type="text/css"> 422 .woocommerce div.product form.cart .button.single_add_to_cart_button{ 423 display: none !important; 424 } 425 </style> 426 <?php 427 } 428 } 429 }*/ 430 431 ?> 432 433 230 <a href="https://wordpress.org/support/plugin/vmi-direct-checkout/reviews/#new-post" target="_blank">Give us a 5 Stars Review</a>'; 231 echo $admin_html; 232 }
Note: See TracChangeset
for help on using the changeset viewer.