Guest User

Untitled

a guest
Jan 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. $first = true;
  2. foreach ( $packages as $package ) {
  3. if ( $first ) {
  4.  
  5. $package = wc_paid_listings_get_package( $package );
  6. $package_id = $package->get_id();
  7.  
  8. $cv_credit = $wpdb->get_row( "SELECT cv_credit, cv_credit_count, cv_credit_duration, date_purchased, credit_value FROM `wp_wcpl_user_packages` WHERE id = $package_id" );
  9.  
  10. $amount_of_credits = $cv_credit->cv_credit; // AMOUNT OF CREDITS THE PACKAGE HAS
  11. $how_many_used = $cv_credit->cv_credit_count; // THE AMOUNT THEY HAVE USED
  12. $credit_value = $cv_credit->credit_value; // WHAT THEY HAVE SEEN (COMMA SEPARATED)
  13. $how_many_left = $amount_of_credits - $how_many_used;
  14. $credit_duration = $cv_credit->cv_credit_duration;
  15. $date_purchased = $cv_credit->date_purchased;
  16.  
  17. $timestamp = strtotime($date_purchased);
  18. $date_purchased_yday = date("d", $timestamp); // day of the year
  19. $dayend = $date_purchased_yday + $credit_duration - 1; // when it ends
  20.  
  21. $today = getdate();
  22. $today_yday = $today["yday"]; // todays day of the year
  23.  
  24. $timeleft = $dayend - $today_yday;
  25.  
  26. if ($timeleft >= "0") {
  27.  
  28. if ($how_many_left >= "1") {
  29.  
  30. $createarrayofvalues = explode(',', $credit_value);
  31.  
  32. if (in_array($post->ID, $createarrayofvalues)) {
  33.  
  34. ?>
  35. <div class="contact-information">
  36. <p>Mobile Number: <?php echo $mobile_number; ?> </p>
  37. <p>Email Address: <?php echo $email; ?> </p>
  38. <p>Links:
  39. <?php the_resume_links(); ?>
  40. </p>
  41. </div>
  42. <?php
  43. } // IF they have paid for the CV before
  44. else {
  45. ?> <a href="#" class="et_pb_button cv_credit">View contact information (<?php echo $how_many_left ?> credit/s left)</a> <?php
  46. }
  47. } // how many left
  48. else {
  49. echo "You have no more credits for this package";
  50. }
  51. }// time left on package
  52. else {
  53. }
  54. $first = false;
  55. } // if First
  56. else {
  57.  
  58. }
  59.  
  60. }
Add Comment
Please, Sign In to add comment