Changeset 1972647
- Timestamp:
- 11/11/2018 10:36:01 PM (7 years ago)
- Location:
- disable-downloadable-repeat-purchase
- Files:
-
- 4 edited
- 1 copied
-
tags/1.2.3 (copied) (copied from disable-downloadable-repeat-purchase/trunk)
-
tags/1.2.3/disable-downloadable-repeat-purchase.php (modified) (10 diffs)
-
tags/1.2.3/readme.txt (modified) (2 diffs)
-
trunk/disable-downloadable-repeat-purchase.php (modified) (10 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
disable-downloadable-repeat-purchase/tags/1.2.3/disable-downloadable-repeat-purchase.php
r1800801 r1972647 4 4 * Plugin URI: https://wordpress.org/plugins/disable-downloadable-repeat-purchase/ 5 5 * Description: Disable the ability for logged in users to purchase items they already own that are downloadable. Links are provided on the product page for ease of re-download. It does not apply to products the customer has been refunded for. It checks if the product has been purchased and is available to download on their account. 6 * Version: 1.2. 26 * Version: 1.2.3 7 7 * Author: MCPat.com 8 8 * Author URI: https://www.mcpat.com … … 13 13 * License: GPLv2 14 14 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 15 * WC requires at least: 3. 0.016 * WC tested up to: 3. 2.615 * WC requires at least: 3.4.0 16 * WC tested up to: 3.5.1 17 17 */ 18 18 … … 205 205 // Get the ID for the current product 206 206 $product_id = $product->get_ID(); 207 208 // check if wpml is active 207 208 //old 209 /*// check if wpml is active 209 210 $multi = false; 210 211 if ( array_key_exists('wpml_object_id', $GLOBALS['wp_filter']) ) { … … 227 228 } 228 229 } 229 } else { 230 } else {*/ 230 231 // return false if the customer has bought the product and is currently available for download 231 232 if ( wc_customer_bought_product( wp_get_current_user()->user_email, get_current_user_id(), $product_id ) && $product->get_downloadable() && get_post_meta( $product_id, '_mcpat_ddrp_is_enabled', true ) != 'no' ) { 232 233 $purchasable = false; 233 234 } 234 }235 //} 235 236 return $purchasable; 236 237 } … … 250 251 if ( $product->is_type( 'variable' ) ) { //variabel product 251 252 foreach ( $product->get_children() as $variation_id ) { 253 /*//Old 252 254 if ($multi) { 253 255 $orig_ppost = apply_filters( 'wpml_object_id',$variation_id, get_post_type( $variation_id ), true, $sitepress->get_default_language() ); … … 255 257 $translations = $sitepress->get_element_translations($trid, 'product'); 256 258 foreach( $translations as $lang=>$translation){ 259 257 260 // Render the purchase restricted message if it has been purchased 258 261 if ( wc_customer_bought_product( wp_get_current_user()->user_email, get_current_user_id(), $translation->element_id ) && get_post_meta( $translation->element_id, '_downloadable', true ) == 'yes' && get_post_meta( $translation->element_id, '_mcpat_ddrp_is_enabled', true ) != 'no' ) { 259 262 mcpat_ddrp_render_variation_non_purchasable_message( $product, $variation_id); 263 echo "<script> console.log('PHP-first: ',",$variation_id,");</script>"; 260 264 //break;//? 261 265 } 262 266 } 263 } else { 264 foreach ( $product->get_children() as $variation_id ) { 265 // Render the purchase restricted message if it has been purchased 267 } else {*/ 266 268 if ( wc_customer_bought_product( wp_get_current_user()->user_email, get_current_user_id(), $variation_id ) && get_post_meta( $variation_id, '_downloadable', true ) == 'yes' && get_post_meta( $variation_id, '_mcpat_ddrp_is_enabled', true ) != 'no' ) { 267 269 mcpat_ddrp_render_variation_non_purchasable_message( $product, $variation_id); 270 echo "<script> console.log('PHP-first-s: ',",$variation_id,");</script>"; 268 271 } 269 } 270 } 272 //} 271 273 } 272 274 } else { //normal product … … 289 291 //jQuery(window).load(function () { 290 292 jQuery(document).ready ( function(){ 291 if (jQuery(window).width() >= 470){292 jQuery(". woocommerce-info").attr('style', 'min-width: 470px; animation-name: slide-in');293 if (jQuery(window).width() >= 500){ 294 jQuery(".page-notifications").attr('style', 'animation-name: slide-in;animation-delay: 0s;animation-duration: 0s;Top:100px;min-width: 500px'); 293 295 } else { 294 jQuery(". woocommerce-info").attr('style', 'animation-name: slide-in');296 jQuery(".page-notifications").attr('style', 'animation-name: slide-in;animation-delay: 0s;animation-duration: 0s;Top:100px'); 295 297 } 296 jQuery(".notice_text").attr('style', 'animation-name: opacity_text_in ');298 jQuery(".notice_text").attr('style', 'animation-name: opacity_text_in;animation-delay: 0s;animation-duration: 0s'); 297 299 }); 298 300 </script><?php … … 351 353 add_action( 'woocommerce_single_product_summary', 'mcpat_ddrp_repeat_purchase_disabled_message', 31 ); 352 354 355 function mcpat_ddrp_render_variation_non_purchasable_message2( $product, $no_repeats_id ) { 356 357 // Double-check we're looking at a variable product 358 if ( $product->is_type( 'variable' ) && $product->has_child() ) { 359 360 $variation_purchasable = true; 361 362 foreach ( $product->get_available_variations() as $variation ) { 363 364 // only show this message for non-purchasable variations matching our ID 365 if ( $no_repeats_id == $variation['variation_id'] ) { 366 $variation_purchasable = false; 367 //echo "<script> console.log('PHP: ',",sanitize_html_class( $variation['variation_id'] ),");</script>"; 368 echo '<div class="woocommerce"><div class="woocommerce-info wc-nonpurchasable-message js-variation-' . sanitize_html_class( $variation['variation_id'] ) . '">You\'ve already purchased this product! It can only be purchased once.</div></div>'; 369 } 370 } 371 } 372 373 if ( ! $variation_purchasable ) { 374 wc_enqueue_js(" 375 jQuery('.variations_form') 376 .on( 'woocommerce_variation_select_change', function( event ) { 377 jQuery('.wc-nonpurchasable-message').hide(); 378 }) 379 .on( 'found_variation', function( event, variation ) { 380 jQuery('.wc-nonpurchasable-message').hide(); 381 if ( ! variation.is_purchasable ) { 382 jQuery( '.wc-nonpurchasable-message.js-variation-' + variation.variation_id ).show(); 383 } 384 }) 385 .find( '.variations select' ).change(); 386 "); 387 } 388 } 353 389 function mcpat_ddrp_render_variation_non_purchasable_message( $product, $no_repeats_id) { 354 390 // Double-check we're looking at a variable product … … 379 415 //jQuery(window).load(function () { 380 416 jQuery(document).ready ( function(){ 381 if (jQuery(window).width() >= 470){382 jQuery(". woocommerce-info").attr('style', 'min-width: 470px; animation-name: slide-in');417 if (jQuery(window).width() >= 500){ 418 jQuery(".page-notifications").attr('style', 'animation-name: slide-in;animation-delay: 0s;animation-duration: 0s;Top:100px;min-width: 500px'); 383 419 } else { 384 jQuery(". woocommerce-info").attr('style', 'animation-name: slide-in');420 jQuery(".page-notifications").attr('style', 'animation-name: slide-in;animation-delay: 0s;animation-duration: 0s;Top:100px'); 385 421 } 386 jQuery(".notice_text").attr('style', 'animation-name: opacity_text_in ');422 jQuery(".notice_text").attr('style', 'animation-name: opacity_text_in;animation-delay: 0s;animation-duration: 0s'); 387 423 }); 388 424 </script><?php … … 477 513 function mcpat_ddrp_is_requirements_met() { 478 514 $min_wp = '4.7'; 479 $min_wc = '3. 0';515 $min_wc = '3.4'; 480 516 481 517 // Check for WordPress version -
disable-downloadable-repeat-purchase/tags/1.2.3/readme.txt
r1800801 r1972647 5 5 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=p%2er%2ewallner%40gmail%2ecom&lc=AT&item_name=mcpat¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted 6 6 Requires at Least: 4.7 7 Tested Up To: 4.97 Tested Up To: 5.0 8 8 Tags: woocommerce, downloads, downloadable, repeat purchase, wordpress, wordpress.org,wpml,multilanguage,language 9 Stable tag: 1.2. 210 WC requires at least: 3. 0.011 WC tested up to: 3. 2.69 Stable tag: 1.2.3 10 WC requires at least: 3.4.0 11 WC tested up to: 3.5.1 12 12 License: GPLv2 or later 13 13 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 59 59 == Changelog == 60 60 61 = 1.2.3 = 62 - Bug fix on variable products 63 61 64 = 1.2.2 = 62 65 - Fix showing expire date -
disable-downloadable-repeat-purchase/trunk/disable-downloadable-repeat-purchase.php
r1800801 r1972647 4 4 * Plugin URI: https://wordpress.org/plugins/disable-downloadable-repeat-purchase/ 5 5 * Description: Disable the ability for logged in users to purchase items they already own that are downloadable. Links are provided on the product page for ease of re-download. It does not apply to products the customer has been refunded for. It checks if the product has been purchased and is available to download on their account. 6 * Version: 1.2. 26 * Version: 1.2.3 7 7 * Author: MCPat.com 8 8 * Author URI: https://www.mcpat.com … … 13 13 * License: GPLv2 14 14 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 15 * WC requires at least: 3. 0.016 * WC tested up to: 3. 2.615 * WC requires at least: 3.4.0 16 * WC tested up to: 3.5.1 17 17 */ 18 18 … … 205 205 // Get the ID for the current product 206 206 $product_id = $product->get_ID(); 207 208 // check if wpml is active 207 208 //old 209 /*// check if wpml is active 209 210 $multi = false; 210 211 if ( array_key_exists('wpml_object_id', $GLOBALS['wp_filter']) ) { … … 227 228 } 228 229 } 229 } else { 230 } else {*/ 230 231 // return false if the customer has bought the product and is currently available for download 231 232 if ( wc_customer_bought_product( wp_get_current_user()->user_email, get_current_user_id(), $product_id ) && $product->get_downloadable() && get_post_meta( $product_id, '_mcpat_ddrp_is_enabled', true ) != 'no' ) { 232 233 $purchasable = false; 233 234 } 234 }235 //} 235 236 return $purchasable; 236 237 } … … 250 251 if ( $product->is_type( 'variable' ) ) { //variabel product 251 252 foreach ( $product->get_children() as $variation_id ) { 253 /*//Old 252 254 if ($multi) { 253 255 $orig_ppost = apply_filters( 'wpml_object_id',$variation_id, get_post_type( $variation_id ), true, $sitepress->get_default_language() ); … … 255 257 $translations = $sitepress->get_element_translations($trid, 'product'); 256 258 foreach( $translations as $lang=>$translation){ 259 257 260 // Render the purchase restricted message if it has been purchased 258 261 if ( wc_customer_bought_product( wp_get_current_user()->user_email, get_current_user_id(), $translation->element_id ) && get_post_meta( $translation->element_id, '_downloadable', true ) == 'yes' && get_post_meta( $translation->element_id, '_mcpat_ddrp_is_enabled', true ) != 'no' ) { 259 262 mcpat_ddrp_render_variation_non_purchasable_message( $product, $variation_id); 263 echo "<script> console.log('PHP-first: ',",$variation_id,");</script>"; 260 264 //break;//? 261 265 } 262 266 } 263 } else { 264 foreach ( $product->get_children() as $variation_id ) { 265 // Render the purchase restricted message if it has been purchased 267 } else {*/ 266 268 if ( wc_customer_bought_product( wp_get_current_user()->user_email, get_current_user_id(), $variation_id ) && get_post_meta( $variation_id, '_downloadable', true ) == 'yes' && get_post_meta( $variation_id, '_mcpat_ddrp_is_enabled', true ) != 'no' ) { 267 269 mcpat_ddrp_render_variation_non_purchasable_message( $product, $variation_id); 270 echo "<script> console.log('PHP-first-s: ',",$variation_id,");</script>"; 268 271 } 269 } 270 } 272 //} 271 273 } 272 274 } else { //normal product … … 289 291 //jQuery(window).load(function () { 290 292 jQuery(document).ready ( function(){ 291 if (jQuery(window).width() >= 470){292 jQuery(". woocommerce-info").attr('style', 'min-width: 470px; animation-name: slide-in');293 if (jQuery(window).width() >= 500){ 294 jQuery(".page-notifications").attr('style', 'animation-name: slide-in;animation-delay: 0s;animation-duration: 0s;Top:100px;min-width: 500px'); 293 295 } else { 294 jQuery(". woocommerce-info").attr('style', 'animation-name: slide-in');296 jQuery(".page-notifications").attr('style', 'animation-name: slide-in;animation-delay: 0s;animation-duration: 0s;Top:100px'); 295 297 } 296 jQuery(".notice_text").attr('style', 'animation-name: opacity_text_in ');298 jQuery(".notice_text").attr('style', 'animation-name: opacity_text_in;animation-delay: 0s;animation-duration: 0s'); 297 299 }); 298 300 </script><?php … … 351 353 add_action( 'woocommerce_single_product_summary', 'mcpat_ddrp_repeat_purchase_disabled_message', 31 ); 352 354 355 function mcpat_ddrp_render_variation_non_purchasable_message2( $product, $no_repeats_id ) { 356 357 // Double-check we're looking at a variable product 358 if ( $product->is_type( 'variable' ) && $product->has_child() ) { 359 360 $variation_purchasable = true; 361 362 foreach ( $product->get_available_variations() as $variation ) { 363 364 // only show this message for non-purchasable variations matching our ID 365 if ( $no_repeats_id == $variation['variation_id'] ) { 366 $variation_purchasable = false; 367 //echo "<script> console.log('PHP: ',",sanitize_html_class( $variation['variation_id'] ),");</script>"; 368 echo '<div class="woocommerce"><div class="woocommerce-info wc-nonpurchasable-message js-variation-' . sanitize_html_class( $variation['variation_id'] ) . '">You\'ve already purchased this product! It can only be purchased once.</div></div>'; 369 } 370 } 371 } 372 373 if ( ! $variation_purchasable ) { 374 wc_enqueue_js(" 375 jQuery('.variations_form') 376 .on( 'woocommerce_variation_select_change', function( event ) { 377 jQuery('.wc-nonpurchasable-message').hide(); 378 }) 379 .on( 'found_variation', function( event, variation ) { 380 jQuery('.wc-nonpurchasable-message').hide(); 381 if ( ! variation.is_purchasable ) { 382 jQuery( '.wc-nonpurchasable-message.js-variation-' + variation.variation_id ).show(); 383 } 384 }) 385 .find( '.variations select' ).change(); 386 "); 387 } 388 } 353 389 function mcpat_ddrp_render_variation_non_purchasable_message( $product, $no_repeats_id) { 354 390 // Double-check we're looking at a variable product … … 379 415 //jQuery(window).load(function () { 380 416 jQuery(document).ready ( function(){ 381 if (jQuery(window).width() >= 470){382 jQuery(". woocommerce-info").attr('style', 'min-width: 470px; animation-name: slide-in');417 if (jQuery(window).width() >= 500){ 418 jQuery(".page-notifications").attr('style', 'animation-name: slide-in;animation-delay: 0s;animation-duration: 0s;Top:100px;min-width: 500px'); 383 419 } else { 384 jQuery(". woocommerce-info").attr('style', 'animation-name: slide-in');420 jQuery(".page-notifications").attr('style', 'animation-name: slide-in;animation-delay: 0s;animation-duration: 0s;Top:100px'); 385 421 } 386 jQuery(".notice_text").attr('style', 'animation-name: opacity_text_in ');422 jQuery(".notice_text").attr('style', 'animation-name: opacity_text_in;animation-delay: 0s;animation-duration: 0s'); 387 423 }); 388 424 </script><?php … … 477 513 function mcpat_ddrp_is_requirements_met() { 478 514 $min_wp = '4.7'; 479 $min_wc = '3. 0';515 $min_wc = '3.4'; 480 516 481 517 // Check for WordPress version -
disable-downloadable-repeat-purchase/trunk/readme.txt
r1800801 r1972647 5 5 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=p%2er%2ewallner%40gmail%2ecom&lc=AT&item_name=mcpat¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted 6 6 Requires at Least: 4.7 7 Tested Up To: 4.97 Tested Up To: 5.0 8 8 Tags: woocommerce, downloads, downloadable, repeat purchase, wordpress, wordpress.org,wpml,multilanguage,language 9 Stable tag: 1.2. 210 WC requires at least: 3. 0.011 WC tested up to: 3. 2.69 Stable tag: 1.2.3 10 WC requires at least: 3.4.0 11 WC tested up to: 3.5.1 12 12 License: GPLv2 or later 13 13 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 59 59 == Changelog == 60 60 61 = 1.2.3 = 62 - Bug fix on variable products 63 61 64 = 1.2.2 = 62 65 - Fix showing expire date
Note: See TracChangeset
for help on using the changeset viewer.