echo absint($payment->ID); ?> </td> <td><?php echo esc_html(date_i18n(get_option('date_format'), strtotime($payment->payment_date))); ?> </td> <td> <?php if (array_key_exists($payment->payment_status, $statuses)) { echo esc_html($statuses[$payment->payment_status]); } ?> </td> <td><?php echo ib_edu_format_price($payment->amount, false); ?> </td> <td class="actions-group"> <?php $invoice_url = ib_edu_get_endpoint_url('edu-thankyou', $payment->ID, get_permalink(ib_edu_page_id('payment'))); ?> <a href="<?php echo esc_url($invoice_url); ?> "><?php _e('Details', 'ibeducator'); ?> </a> <?php
/** * Output the Stripe's payment dialog. * Step 2 in the payment process. */ public function pay_page() { $payment_id = absint(get_query_var('edu-pay')); if (!$payment_id) { return; } $user = wp_get_current_user(); if (0 == $user->ID) { return; } $payment = edr_get_payment($payment_id); if (!$payment->ID || $user->ID != $payment->user_id) { // The payment must exist and it must be associated with the current user. return; } if ('course' == $payment->payment_type) { $post = get_post($payment->course_id); } elseif ('membership' == $payment->payment_type) { $post = get_post($payment->object_id); } if (!$post) { return; } ?> <p id="ib-edu-payment-processing-msg"> <?php _e('The payment is getting processed...', 'ibeducator'); ?> </p> <script src="https://checkout.stripe.com/checkout.js"></script> <script> (function($) { var handler = StripeCheckout.configure({ key: <?php echo json_encode($this->get_option('publishable_key')); ?> , image: '', email: <?php echo json_encode($user->user_email); ?> , token: function(token) { $.ajax({ type: 'POST', cache: false, url: <?php echo json_encode(ib_edu_request_url('stripe_token')); ?> , data: { payment_id: <?php echo intval($payment->ID); ?> , token: token.id, _wpnonce: <?php echo json_encode(wp_create_nonce('ib_educator_stripe_token')); ?> }, success: function(response) { if (response === '1') { $('#ib-edu-payment-processing-msg').text(<?php echo json_encode(__('Redirecting to the payment summary page...', 'ibeducator')); ?> ); var redirectTo = <?php echo json_encode(ib_edu_get_endpoint_url('edu-thankyou', $payment->ID, get_permalink(ib_edu_page_id('payment')))); ?> ; document.location = redirectTo; } } }); } }); handler.open({ name: <?php echo json_encode(esc_html($post->post_title)); ?> , description: <?php echo json_encode(ib_edu_format_price($payment->amount, false, false)); ?> , currency: <?php echo json_encode(ib_edu_get_currency()); ?> , amount: <?php echo absint($payment->amount * 100); ?> }); $(window).on('popstate', function() { handler.close(); }); })(jQuery); </script> <?php }
/** * Get payment info table. * * @param WP_Post $object * @param array $args * @return string */ public static function payment_info($object, $args = array()) { // Get price. if (!isset($args['price'])) { if ('ib_educator_course' == $object->post_type) { $args['price'] = ib_edu_get_course_price($object->ID); } elseif ('ib_edu_membership' == $object->post_type) { $args['price'] = IB_Educator_Memberships::get_instance()->get_price($object->ID); } } // Get tax data. $tax_enabled = ib_edu_get_option('enable', 'taxes'); if ($tax_enabled) { $edu_tax = IB_Educator_Tax::get_instance(); $tax_data = $edu_tax->calculate_tax($edu_tax->get_tax_class_for($object->ID), $args['price'], $args['country'], $args['state']); } else { $tax_data = array('taxes' => array(), 'subtotal' => $args['price'], 'tax' => 0.0, 'total' => $args['price']); } // Items list. $output = '<table class="edu-payment-table">'; $output .= '<thead><tr><th>' . __('Item', 'ibeducator') . '</th><th>' . __('Price', 'ibeducator') . '</th></tr></thead>'; if ('ib_educator_course' == $object->post_type) { $output .= '<tbody><tr><td>'; if (ib_edu_get_option('payment_lecturer', 'settings')) { $output .= sprintf(__('%s with %s', 'ibeducator'), '<a href="' . esc_url(get_permalink($object->ID)) . '" target="_blank">' . esc_html($object->post_title) . '</a>', esc_html(get_the_author_meta('display_name', $object->post_author))); } else { $output .= '<a href="' . esc_url(get_permalink($object->ID)) . '" target="_blank">' . esc_html($object->post_title) . '</a>'; } $output .= '<input type="hidden" id="payment-object-id" name="course_id" value="' . intval($object->ID) . '"></td>'; $output .= '<td>' . ib_edu_format_price($tax_data['subtotal'], false) . '</td></tr></tbody>'; } elseif ('ib_edu_membership' == $object->post_type) { $output .= '<tbody><tr><td>' . esc_html($object->post_title); $output .= '<input type="hidden" id="payment-object-id" name="membership_id" value="' . intval($object->ID) . '"></td>'; $ms = IB_Educator_Memberships::get_instance(); $membership_meta = $ms->get_membership_meta($object->ID); $output .= '<td>' . $ms->format_price($tax_data['subtotal'], $membership_meta['duration'], $membership_meta['period']) . '</td></tr></tbody>'; } $output .= '</table>'; // Summary. $output .= '<dl class="edu-payment-summary edu-dl">'; if ($tax_data['tax'] > 0.0) { $output .= '<dt class="payment-subtotal">' . __('Subtotal', 'ibeducator') . '</dt><dd>' . ib_edu_format_price($tax_data['subtotal'], false) . '</dd>'; foreach ($tax_data['taxes'] as $tax) { $output .= '<dt class="payment-tax">' . esc_html($tax->name) . '</dt><dd>' . ib_edu_format_price($tax->amount, false) . '</dd>'; } } $output .= '<dt class="payment-total">' . __('Total', 'ibeducator') . '</dt><dd>' . ib_edu_format_price($tax_data['total'], false) . '</dd>'; $output .= '</dl>'; return $output; }
the_post_thumbnail('ib-educator-grid'); ?> </a> </div> <?php } ?> <div class="post-body"> <?php the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>'); ?> <div class="price"> <?php if ('closed' != ib_edu_registration($course_id)) { echo ib_edu_format_price(ib_edu_get_course_price($course_id)); } ?> </div> <div class="post-excerpt"><?php the_excerpt(); ?> </div> </div> <footer class="post-meta"> <?php echo educator_course_meta($course_id, array('num_lessons', 'difficulty')); echo educator_share('menu'); ?> </footer>
/** * Format course price. * * @param float $price * @return string */ function ib_edu_format_course_price($price) { return ib_edu_format_price($price); }
/** * Get the membership price widget. * * @param int $membership_id * @return string */ public function get_price_widget($membership_id = null) { if (is_null($membership_id)) { $membership_id = get_the_ID(); } $output = apply_filters('ib_educator_membership_price_widget', null, $membership_id); if (!is_null($output)) { return $output; } $price = $this->get_price($membership_id); $payment_url = ib_edu_get_endpoint_url('edu-membership', $membership_id, get_permalink(ib_edu_page_id('payment'))); $output = '<div class="ib-edu-price-widget">'; $output .= '<span class="price">' . ib_edu_format_price($price) . '</span>'; $output .= '<a href="' . esc_url($payment_url) . '" class="ib-edu-button">' . __('Purchase', 'ibeducator') . '</a>'; $output .= '</div>'; return $output; }
?> </a> <div class="ib-edu-course-price"> <?php if (ib_edu_get_course_price(get_the_ID()) == 0) { ?> <span class="label-free"><?php esc_html_e('Free', 'training'); ?> </span> <?php } else { ?> <span><?php echo ib_edu_format_price(ib_edu_get_course_price(get_the_ID())); ?> </span> <?php } ?> </div> </div> <?php } ?> <div class="course-inner"> <div class="course-header"> <h4><a href="<?php echo esc_url($link);