Advertisement
rejuancse

dfdsa

Oct 2nd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.50 KB | None | 0 0
  1. <!-- Quantity Box WooCommerce -->
  2. <?php
  3.     if ( ! defined( 'ABSPATH' ) ) {
  4.         exit; # Exit if accessed directly
  5.    }
  6.     global $post, $woocommerce, $product;
  7.     $currency = '$';
  8.     if ($product->get_type() == 'crowdfunding') {
  9.         if (WPNEOCF()->campaignValid()) {
  10.             $recomanded_price = get_post_meta($post->ID, 'wpneo_funding_recommended_price', true);
  11.             $min_price = get_post_meta($post->ID, 'wpneo_funding_minimum_price', true);
  12.             $max_price = get_post_meta($post->ID, 'wpneo_funding_maximum_price', true);
  13.             if(function_exists( 'get_woocommerce_currency_symbol' )){
  14.                 $currency = get_woocommerce_currency_symbol();
  15.             }
  16.  
  17.             if (! empty($_GET['reward_min_amount'])){
  18.                 $recomanded_price = (int) esc_html($_GET['reward_min_amount']);
  19.             } ?>
  20.  
  21.             <?php
  22.             $_nf_duration_end = get_post_meta(get_the_ID(), '_nf_duration_end', true);
  23.             $end_method = get_post_meta(get_the_ID(), 'wpneo_campaign_end_method', true);
  24.  
  25.             $today = strtotime((new DateTime())->format('d-m-Y'));
  26.             $expiry = strtotime((new DateTime($_nf_duration_end))->format('d-m-Y'));
  27.             $fundraised = WPNEOCF()->getFundRaisedPercent();
  28.  
  29.             # Campaign Valid.  
  30.  
  31.             if ( ($end_method == 'target_goal' && $fundraised >= '100') || ($end_method == 'target_date' && $today > $expiry) || ($end_method == 'target_goal_and_date' && ($fundraised >= '100' || $today > $expiry) ) ) {  ?>
  32.                 <div class="overlay until-date ">
  33.                     <div>
  34.                         <div>
  35.                             <span class="info-text"><?php _e( 'Campaign Over','wp-crowdfunding' ); ?></span>
  36.                         </div>
  37.                     </div>
  38.                 </div>
  39.             <?php } else { ?>
  40.  
  41.                 <div id="backnow_project" class="quantity_box">
  42.                     <span><?php _e('Make a pledge without a reward AA', 'backnow'); ?> </span>
  43.                     <span class="wpneo-tooltip">
  44.                         <span class="wpneo-tooltip-min"><?php _e('Minimum amount is ','backnow'); echo esc_attr($currency.$min_price); ?></span>
  45.                         <span class="wpneo-tooltip-max"><?php _e('Maximum amount is ','backnow'); echo esc_attr($currency.$max_price); ?></span>
  46.                     </span>
  47.                     <form enctype="multipart/form-data" method="post" class="cart">
  48.                         <?php do_action('before_wpneo_donate_field'); ?>
  49.                         <input type="number" min="0" placeholder="" name="wpneo_donate_amount_field" class="input-text amount wpneo_donate_amount_field text" value="<?php echo esc_attr($recomanded_price); ?>" data-min-price="<?php echo esc_attr($min_price) ?>" data-max-price="<?php echo esc_attr($max_price) ?>" >
  50.                         <?php do_action('after_wpneo_donate_field'); ?>
  51.                         <input type="hidden" value="<?php echo esc_attr($post->ID); ?>" name="add-to-cart">
  52.                         <button type="submit" class="q<?php echo apply_filters('add_to_donate_button_class', 'wpneo_donate_button'); ?>"><i class="fa fa-long-arrow-right"></i></button>
  53.                     </form>
  54.                 </div>
  55.  
  56.             <?php } ?>
  57.  
  58.            
  59.         <?php }
  60.     }
  61. ?>
  62. <!-- Quantity Box End -->
  63. <br>
  64. <span id="backnow_project_demo" class="backnow-rewards">
  65.     <span><?php _e('Rewards', 'backnow'); ?></span>
  66. </span>
  67.  
  68. <?php
  69.     global $post;
  70.     $campaign_rewards   = get_post_meta($post->ID, 'wpneo_reward', true);
  71.     $campaign_rewards   = stripslashes($campaign_rewards);
  72.     $campaign_rewards_a = json_decode($campaign_rewards, true);
  73.     if (is_array($campaign_rewards_a)) {
  74.         if (count($campaign_rewards_a) > 0) {
  75.  
  76.             $i      = 0;
  77.             $amount = array();
  78.  
  79.             foreach ($campaign_rewards_a as $key => $row) {
  80.                 $amount[$key] = $row['wpneo_rewards_pladge_amount'];
  81.             }
  82.             array_multisort($amount, SORT_ASC, $campaign_rewards_a);
  83.            
  84.             foreach ($campaign_rewards_a as $key => $value) {
  85.                 $key++;
  86.                 $i++;
  87.                 $quantity = '';
  88.                
  89.                 $post_id    = get_the_ID();
  90.                 $min_data   = $value['wpneo_rewards_pladge_amount'];
  91.                 $max_data   = '';
  92.                 $orders     = 0;
  93.                 ( ! empty($campaign_rewards_a[$i]['wpneo_rewards_pladge_amount']))? ( $max_data = $campaign_rewards_a[$i]['wpneo_rewards_pladge_amount'] - 1 ) : ($max_data = 9000000000);
  94.                 if( $min_data != '' ){
  95.                     $orders = wpneo_campaign_order_number_data( $min_data,$max_data,$post_id );
  96.                 }
  97.                 if( $value['wpneo_rewards_item_limit'] ){
  98.                     $quantity = 0;
  99.                     if( $value['wpneo_rewards_item_limit'] >= $orders ){
  100.                         $quantity = $value['wpneo_rewards_item_limit'] - $orders;
  101.                     }
  102.                 }
  103.             ?>
  104.  
  105.             <div class="tab-rewards-wrapper<?php echo ( $quantity === 0 ) ? ' disable' : ''; ?>">
  106.                 <?php if( $value['wpneo_rewards_image_field'] ){ ?>
  107.                     <div class="wpneo-rewards-image">
  108.                         <?php echo '<img src="'.wp_get_attachment_url( $value["wpneo_rewards_image_field"] ).'"/>'; ?>
  109.                     </div>
  110.                 <?php } ?>
  111.                 <div class="backnow-reward-cont">
  112.                     <h3>
  113.                         <?php echo get_woocommerce_currency_symbol(). $value['wpneo_rewards_pladge_amount'];
  114.                             if( 'true' != get_option('wpneo_reward_fixed_price','') ){
  115.                                 echo ( ! empty($campaign_rewards_a[$i]['wpneo_rewards_pladge_amount']))? ' - '. get_woocommerce_currency_symbol(). ($campaign_rewards_a[$i]['wpneo_rewards_pladge_amount'] - 1) : ' - more';    
  116.                             }
  117.                         ?>
  118.                     </h3>
  119.                     <p><?php echo esc_html($value['wpneo_rewards_description']); ?></p>
  120.                     <?php if( $min_data != '' ){
  121.                         echo '<p>'.$orders.' '.__('backnows','backnow').'</p>'; } ?>
  122.  
  123.  
  124.                         <?php
  125.  
  126.                         $est_delivery = ucfirst(date_i18n("M", strtotime($value['wpneo_rewards_endmonth']))).', '.$value['wpneo_rewards_endyear'];
  127.                         if ( ! empty($value['wpneo_rewards_endmonth']) || ! empty($value['wpneo_rewards_endyear'])){ ?>
  128.                             <div class="backnow-estimate-date">
  129.                                 <?php
  130.                                     echo '<span>'.__('Estimated Delivery: ', 'backnow').'</span>';
  131.                                     echo "<span>{$est_delivery}</span>";
  132.                                 ?>
  133.                             </div>
  134.                     <?php } ?>
  135.  
  136.  
  137.  
  138.                 <?php
  139.                  # Metabox Call
  140.                    $_nf_duration_end = get_post_meta(get_the_ID(), '_nf_duration_end', true);
  141.                     $end_method = get_post_meta(get_the_ID(), 'wpneo_campaign_end_method', true);
  142.                     $today = strtotime((new DateTime())->format('d-m-Y'));
  143.                     $expiry = strtotime((new DateTime($_nf_duration_end))->format('d-m-Y'));
  144.                     $fundraised = WPNEOCF()->getFundRaisedPercent();
  145.                    
  146.                     # Campaign Valid.                      
  147.                    if ( ($end_method == 'target_goal' && $fundraised >= '100') || ($end_method == 'target_date' && $today > $expiry) || ($end_method == 'target_goal_and_date' && ($fundraised >= '100' || $today > $expiry) ) ) {  ?>
  148.                         <div class="overlay until-date ">
  149.                             <div>
  150.                                 <div>
  151.                                     <span class="info-text"><?php _e( 'Campaign Over','wp-crowdfunding' ); ?></span>
  152.                                 </div>
  153.                             </div>
  154.                         </div>
  155.                     <?php } else { ?>
  156.                         <?php if (WPNEOCF()->campaignValid()) { ?>
  157.                             <?php if (WPNEOCF()->is_campaign_started()) {
  158.                                 if (get_option('wpneo_single_page_reward_design') == 1) { ?>
  159.                                     <div class="overlay">
  160.                                         <div>
  161.                                             <div>
  162.                                                 <?php if( $quantity === 0 ){ ?>
  163.                                                     <span class="wpneo-error"><?php _e( 'Reward no longer available.', 'wp-crowdfunding' ); ?></span>
  164.                                                 <?php } else { ?>
  165.                                                     <form enctype="multipart/form-data" method="post" class="cart">
  166.                                                         <input type="hidden" value="<?php echo $value['wpneo_rewards_pladge_amount']; ?>" name="wpneo_donate_amount_field" />
  167.                                                         <input type="hidden" value="<?php echo esc_attr(serialize($value)); ?>" name="wpneo_selected_rewards_checkout" />
  168.                                                         <input type="hidden" value="<?php echo $key; ?>" name="wpneo_rewards_index" />
  169.                                                         <input type="hidden" value="<?php echo esc_attr($post->post_author); ?>" name="_cf_product_author_id">
  170.                                                         <input type="hidden" value="<?php echo esc_attr($post->ID); ?>" name="add-to-cart">
  171.                                                         <button type="submit" class="select_rewards_button"><?php _e('Select Reward','wp-crowdfunding'); ?></button>
  172.                                                     </form>
  173.                                                 <?php } ?>
  174.                                             </div>
  175.                                         </div>
  176.                                     </div>
  177.                                 <?php } else if (get_option('wpneo_single_page_reward_design') == 2){ ?>
  178.                                     <div class="tab-rewards-submit-form-style1">
  179.                                         <?php if( $quantity === 0 ): ?>
  180.                                             <span class="wpneo-error"><?php _e( 'Reward no longer available.', 'wp-crowdfunding' ); ?></span>
  181.                                         <?php else: ?>
  182.                                             <form enctype="multipart/form-data" method="post" class="cart">
  183.                                                 <input type="hidden" value="<?php echo $value['wpneo_rewards_pladge_amount']; ?>" name="wpneo_donate_amount_field" />
  184.                                                 <input type="hidden" value="<?php echo esc_attr(serialize($value)); ?>" name="wpneo_selected_rewards_checkout" />
  185.                                                 <input type="hidden" value="<?php echo $key; ?>" name="wpneo_rewards_index" />
  186.                                                 <input type="hidden" value="<?php echo esc_attr($post->post_author); ?>" name="_cf_product_author_id">
  187.                                                 <input type="hidden" value="<?php echo esc_attr($post->ID); ?>" name="add-to-cart">
  188.                                                 <button type="submit" class="select_rewards_button"><?php _e('Select Reward','wp-crowdfunding'); ?></button>
  189.                                             </form>
  190.                                         <?php endif; ?>
  191.                                     </div>
  192.                                 <?php } ?>
  193.                             <?php } ?>
  194.                         <?php }else { ?>
  195.                             <div class="overlay until-date">
  196.                                 <div>
  197.                                     <div>
  198.                                         <p class="funding-amount"><?php echo WPNEOCF()->days_until_launch(); ?></p>
  199.                                         <span class="info-text"><?php _e( 'Days Until Launch','wp-crowdfunding' ); ?></span>
  200.                                     </div>
  201.                                 </div>
  202.                             </div>
  203.                         <?php } ?>
  204.                     <?php } ?>
  205.                     <!-- Campaign Over -->
  206.  
  207.  
  208.                 </div>
  209.             </div>
  210.             <?php
  211.             }
  212.         }
  213.     }
  214. ?>
  215. <div style="clear: both"></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement