File: /home/bt667/public_html/wp-content/plugins/easy-digital-downloads/templates/shortcode-receipt.php
<?php
/**
* Shortcode: Receipt - [edd_receipt]
*
* @package EDD
* @category Template
*
* @since 3.0 Check status of order item when showing download link, instead of order itself.
* Show "Refunded" next to any refunded order items.
*/
global $edd_receipt_args;
$order = edd_get_order( $edd_receipt_args['id'] );
// Display a notice if the order was not found in the database.
if ( ! $order ) : ?>
<div class="edd_errors edd-alert edd-alert-error">
<?php esc_html_e( 'The specified receipt ID appears to be invalid.', 'easy-digital-downloads' ); ?>
</div>
<?php
return;
endif;
/**
* Allows additional output before displaying the receipt table.
*
* @since 3.0
*
* @param \EDD\Orders\Order $order Current order.
* @param array $edd_receipt_args [edd_receipt] shortcode arguments.
*/
do_action( 'edd_order_receipt_before_table', $order, $edd_receipt_args );
?>
<table id="edd_purchase_receipt" class="edd-table">
<thead>
<?php do_action( 'edd_order_receipt_before', $order, $edd_receipt_args ); ?>
<?php if ( filter_var( $edd_receipt_args['payment_id'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
<tr>
<th><strong><?php echo esc_html_x( 'Order', 'heading', 'easy-digital-downloads' ); ?>:</strong></th>
<th><?php echo esc_html( $order->get_number() ); ?></th>
</tr>
<?php endif; ?>
</thead>
<tbody>
<tr>
<td class="edd_receipt_payment_status"><strong><?php esc_html_e( 'Order Status', 'easy-digital-downloads' ); ?>:</strong></td>
<td class="edd_receipt_payment_status <?php echo esc_attr( strtolower( $order->status ) ); ?>"><?php echo esc_html( edd_get_status_label( $order->status ) ); ?></td>
</tr>
<?php if ( filter_var( $edd_receipt_args['payment_key'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
<tr>
<td><strong><?php esc_html_e( 'Payment Key', 'easy-digital-downloads' ); ?>:</strong></td>
<td><?php echo esc_html( $order->payment_key ); ?></td>
</tr>
<?php endif; ?>
<?php if ( filter_var( $edd_receipt_args['payment_method'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
<tr>
<td><strong><?php esc_html_e( 'Payment Method', 'easy-digital-downloads' ); ?>:</strong></td>
<td><?php echo esc_html( edd_get_gateway_checkout_label( $order->gateway ) ); ?></td>
</tr>
<?php endif; ?>
<?php if ( filter_var( $edd_receipt_args['date'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
<tr>
<td><strong><?php esc_html_e( 'Date', 'easy-digital-downloads' ); ?>:</strong></td>
<td><?php echo esc_html( edd_date_i18n( EDD()->utils->date( $order->date_created, null, true )->toDateTimeString() ) ); ?></td>
</tr>
<?php endif; ?>
<?php if ( filter_var( $edd_receipt_args['price'], FILTER_VALIDATE_BOOLEAN ) && $order->subtotal > 0 ) : ?>
<tr>
<td><strong><?php esc_html_e( 'Subtotal', 'easy-digital-downloads' ); ?>:</strong></td>
<td>
<?php echo esc_html( edd_payment_subtotal( $order->id ) ); ?>
</td>
</tr>
<?php endif; ?>
<?php
if ( filter_var( $edd_receipt_args['discount'], FILTER_VALIDATE_BOOLEAN ) ) :
$order_discounts = $order->get_discounts();
if ( $order_discounts ) :
$label = _n( 'Discount', 'Discounts', count( $order_discounts ), 'easy-digital-downloads' );
?>
<tr>
<td colspan="2"><strong><?php echo esc_html( $label ); ?>:</strong></td>
</tr>
<?php
foreach ( $order_discounts as $order_discount ) {
$label = $order_discount->description;
if ( 'percent' === edd_get_discount_type( $order_discount->type_id ) ) {
$rate = edd_format_discount_rate( 'percent', edd_get_discount_amount( $order_discount->type_id ) );
$label .= " ({$rate})";
}
?>
<tr>
<td><?php echo esc_html( $label ); ?></td>
<td><?php echo esc_html( edd_display_amount( edd_negate_amount( $order_discount->total ), $order->currency ) ); ?></td>
</tr>
<?php
}
?>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php
$fees = $order->get_fees();
if ( ! empty( $fees ) ) :
?>
<tr>
<td colspan="2"><strong><?php echo esc_html( _n( 'Fee', 'Fees', count( $fees ), 'easy-digital-downloads' ) ); ?>:</strong></td>
</tr>
<?php
foreach ( $fees as $fee ) :
$label = __( 'Fee', 'easy-digital-downloads' );
if ( ! empty( $fee->description ) ) {
$label = $fee->description;
}
?>
<tr>
<td><span class="edd_fee_label"><?php echo esc_html( $label ); ?></span></td>
<td><span class="edd_fee_amount"><?php echo esc_html( edd_display_amount( $fee->subtotal, $order->currency ) ); ?></span></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php if ( $order->tax > 0 ) : ?>
<tr>
<td><strong><?php esc_html_e( 'Tax', 'easy-digital-downloads' ); ?>:</strong></td>
<td><?php echo esc_html( edd_payment_tax( $order->id ) ); ?></td>
</tr>
<?php endif; ?>
<?php
$credits = $order->get_credits();
if ( $credits ) {
?>
<tr>
<td colspan="2"><strong><?php echo esc_html( _n( 'Credit', 'Credits', count( $credits ), 'easy-digital-downloads' ) ); ?>:</strong></td>
</tr>
<?php
foreach ( $credits as $credit ) {
$label = __( 'Credit', 'easy-digital-downloads' );
if ( ! empty( $credit->description ) ) {
$label = $credit->description;
}
?>
<tr>
<td><?php echo esc_html( $label ); ?></td>
<td><?php echo esc_html( edd_display_amount( edd_negate_amount( $credit->total ), $order->currency ) ); ?></td>
</tr>
<?php
}
}
?>
<?php if ( filter_var( $edd_receipt_args['price'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
<tr>
<td><strong><?php esc_html_e( 'Total', 'easy-digital-downloads' ); ?>:</strong></td>
<td><?php echo esc_html( edd_payment_amount( $order->id ) ); ?></td>
</tr>
<?php endif; ?>
<?php
/**
* Fires at the end of the order receipt `tbody`.
*
* @since 3.0
* @param \EDD\Orders\Order $order Current order.
* @param array $edd_receipt_args [edd_receipt] shortcode arguments.
*/
do_action( 'edd_order_receipt_after', $order, $edd_receipt_args );
?>
</tbody>
</table>
<?php
/**
* Fires after the order receipt table.
*
* @since 3.0
* @param \EDD\Orders\Order $order Current order.
* @param array $edd_receipt_args [edd_receipt] shortcode arguments.
*/
do_action( 'edd_order_receipt_after_table', $order, $edd_receipt_args );
if ( ! filter_var( $edd_receipt_args['products'], FILTER_VALIDATE_BOOLEAN ) ) {
return;
}
$order_items = $order->get_items();
if ( empty( $order_items ) ) {
return;
}
?>
<h3><?php echo esc_html( apply_filters( 'edd_payment_receipt_products_title', __( 'Products', 'easy-digital-downloads' ) ) ); ?></h3>
<table id="edd_purchase_receipt_products" class="edd-table">
<thead>
<th style="width: 25%;"><?php esc_html_e( 'Name', 'easy-digital-downloads' ); ?></th>
<?php if ( edd_use_skus() ) { ?>
<th style="width: 10%;"><?php esc_html_e( 'SKU', 'easy-digital-downloads' ); ?></th>
<?php } ?>
<?php if ( edd_item_quantities_enabled() ) : ?>
<th style="width: 10%;"><?php esc_html_e( 'Quantity', 'easy-digital-downloads' ); ?></th>
<?php endif; ?>
<th style="width: 10%;"><?php esc_html_e( 'Price', 'easy-digital-downloads' ); ?></th>
<th style="width: 30%;"><?php esc_html_e( 'Licenses Key', 'easy-digital-downloads' ); ?></th>
<th style="width: 35%"><?php esc_html_e( 'Domain Name', 'easy-digital-downloads' ); ?></th>
</thead>
<tbody>
<?php foreach ( $order_items as $key => $item ) : ?>
<?php
// Skip this item if we can't view it.
if ( ! apply_filters( 'edd_user_can_view_receipt_item', true, $item ) ) {
continue;
}
?>
<tr>
<td>
<?php $download_files = edd_get_download_files( $item->product_id, $item->price_id ); ?>
<div class="edd_purchase_receipt_product_name">
<?php
echo esc_html( $item->product_name );
if ( ! empty( $item->status ) && 'complete' !== $item->status ) {
echo ' – ' . esc_html( edd_get_status_label( $item->status ) );
}
?>
</div>
<?php
//$notes = edd_get_product_notes( $item->product_id );
if ( ! empty( $notes ) ) : ?>
<div class="edd_purchase_receipt_product_notes"><?php //echo wp_kses_post( wpautop( $notes ) ); ?></div>
<?php endif; ?>
<?php if ( 'refunded' !== $item->status && edd_receipt_show_download_files( $item->product_id, $edd_receipt_args, $item ) ) : ?>
<ul class="edd_purchase_receipt_files">
<?php
if ( ! empty( $download_files ) && is_array( $download_files ) ) :
foreach ( $download_files as $filekey => $file ) :
?>
<li class="edd_download_file">
<a href="<?php echo esc_url( edd_get_download_file_url( $order->payment_key, $order->email, $filekey, $item->product_id, $item->price_id ) ); ?>" class="edd_download_file_link" style="color: #0275d8;"><?php echo esc_html( edd_get_file_name( $file ) ); ?></a>
</li>
<?php
/**
* Fires at the end of the order receipt files list.
*
* @since 3.0
* @param int $filekey Index of array of files returned by edd_get_download_files() that this download link is for.
* @param array $file The array of file information.
* @param int $item->product_id The product ID.
* @param int $order->id The order ID.
*/
do_action( 'edd_order_receipt_files', $filekey, $file, $item->product_id, $order->id );
endforeach;
elseif ( edd_is_bundled_product( $item->product_id ) ) :
$bundled_products = edd_get_bundled_products( $item->product_id, $item->price_id );
foreach ( $bundled_products as $bundle_item ) :
?>
<li class="edd_bundled_product">
<span class="edd_bundled_product_name"><?php echo esc_html( edd_get_bundle_item_title( $bundle_item ) ); ?></span>
<ul class="edd_bundled_product_files">
<?php
$bundle_item_id = edd_get_bundle_item_id( $bundle_item );
$bundle_item_price_id = edd_get_bundle_item_price_id( $bundle_item );
$download_files = edd_get_download_files( $bundle_item_id, $bundle_item_price_id );
if ( $download_files && is_array( $download_files ) ) :
foreach ( $download_files as $filekey => $file ) :
?>
<li class="edd_download_file">
<a href="<?php echo esc_url( edd_get_download_file_url( $order->payment_key, $order->email, $filekey, $bundle_item, $bundle_item_price_id ) ); ?>" class="edd_download_file_link"><?php echo esc_html( edd_get_file_name( $file ) ); ?></a>
</li>
<?php
/**
* Fires at the end of the order receipt bundled files list.
*
* @since 3.0
* @param int $filekey Index of array of files returned by edd_get_download_files() that this download link is for.
* @param array $file The array of file information.
* @param int $item->product_id The product ID.
* @param array $bundle_item The array of information about the bundled item.
* @param int $order->id The order ID.
*/
do_action( 'edd_order_receipt_bundle_files', $filekey, $file, $item->product_id, $bundle_item, $order->id );
endforeach;
else :
echo '<li>' . esc_html__( 'No downloadable files found for this bundled item.', 'easy-digital-downloads' ) . '</li>';
endif;
?>
</ul>
</li>
<?php
endforeach;
else :
echo '<li>' . esc_html( apply_filters( 'edd_receipt_no_files_found_text', __( 'No downloadable files found.', 'easy-digital-downloads' ), $item->product_id ) ) . '</li>';
endif;
?>
</ul>
<?php endif; ?>
<?php
/**
* Allow extensions to extend the product cell.
* @since 3.0
* @param \EDD\Orders\Order_Item $item The current order item.
* @param \EDD\Orders\Order $order The current order object.
*/
do_action( 'edd_order_receipt_after_files', $item, $order );
?>
</td>
<?php if ( edd_use_skus() ) : ?>
<td><?php echo esc_html( edd_get_download_sku( $item->product_id ) ); ?></td>
<?php endif; ?>
<?php if ( edd_item_quantities_enabled() ) { ?>
<td><?php echo esc_html( $item->quantity ); ?></td>
<?php } ?>
<td>
<?php echo esc_html( edd_display_amount( $item->total, $order->currency ) ); ?>
</td>
<td>
<?php
global $wpdb;
$order_number = $order->order_number;
$order_id = $order->id;
define( 'SLM_TBL_LICENSE_KEYS', $wpdb->prefix . 'lic_key_tbl' );
$tbl_name = SLM_TBL_LICENSE_KEYS;
$tbl_order_name = $wpdb->prefix.'edd_order_transactions';
if( (!empty($_SESSION['edd'])) && (isset($_SESSION['edd']['edd_purchase'])) ){
$edd = json_decode($_SESSION['edd']['edd_purchase']);
$order_id = $order->get_number();
$order_sql_prep = $wpdb->prepare( "SELECT * FROM $tbl_order_name WHERE `object_id` = %s", $order_id);
$order_record = $wpdb->get_row( $order_sql_prep, OBJECT );
$sql_prep = $wpdb->prepare( "SELECT * FROM $tbl_name WHERE email = %s", $edd->post_data->edd_email);
$record = $wpdb->get_row( $sql_prep, OBJECT );
//echo "<pre>";print_r($record);exit;
if( (isset($edd->post_data)) && (isset($record->license_key)) && (!empty($record->domain)) ){
$transaction_id = $order_record->transaction_id;
$edd_action_license_key = $record->license_key;
$domain = $record->domain;
$execute = $wpdb->query("UPDATE $tbl_name SET `txn_id` = '$transaction_id',`order_id`= $order->id, `domain`= '$domain' WHERE `license_key` = '$edd_action_license_key'");
}elseif((isset($edd->post_data)) && (!empty($record->license_key))){
//echo "<pre>";print_r("UPDATE $tbl_name SET `txn_id` = '$order_record->transaction_id',`order_id`= $order->id WHERE `license_key` = '$record->license_key'");exit;
$transaction_id = $order_record->transaction_id;
$edd_action_license_key = $record->license_key;
$execute = $wpdb->query("UPDATE $tbl_name SET `txn_id` = '$transaction_id',`order_id`= $order->id WHERE `license_key` = '$edd_action_license_key'");
}else{
$edd_action_license_key = '';
}
}else{
$edd_action_license_key = '';
}
?>
<style>
.copy_btn{
padding: 4.5px 7px !important;
color: #ffffff !important;
border-radius: 3px !important;
font-size: 13px !important;
}
</style>
<div class="clipboard">
<input onclick="copyvideocodelicense_key()" class="copy-input" value="<?php echo $edd_action_license_key ?>" id="copyClipboardVideolicense_key" readonly="" style="font-size: 18px;width: auto;border: 0px">
<button class="copyButton" id="copyButtonlicense_key" >Copy</button>
</div>
<div id="copied-success" class="copied">
<span>Copied!</span>
</div>
</td>
<td>
<?php
$tbl_name = SLM_TBL_LICENSE_KEYS;
$edd_domain ='';
if( (!empty($_SESSION['edd'])) && (isset($_SESSION['edd']['edd_purchase'])) ){
$edd = json_decode($_SESSION['edd']['edd_purchase']);
$sql_prep = $wpdb->prepare( "SELECT * FROM $tbl_name WHERE email = %s", $edd->post_data->edd_email);
$record = $wpdb->get_row( $sql_prep, OBJECT );
if((isset($record->domain))){
echo $edd_domain = $record->domain;
}
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<style>
.copyButton {
background-color: #f3f3f3;
padding: 5px 20px;
letter-spacing: .6px;
font-size: 15px;
box-shadow: inset 0 3px transparent;
display: inline-block;
margin-top: 5px;
color: #000;
cursor: pointer;
}
.copied {
width: auto;
display: none;
position: absolute;
color: #000;
padding: 15px 15px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 3px 15px #b8c6db;
-moz-box-shadow: 0 3px 15px #b8c6db;
-webkit-box-shadow: 0 3px 15px #b8c6db;
}
</style>
<script>
jQuery("document").ready(function(){
jQuery("#copyButtonlicense_key").on("click",function(e){
e.preventDefault();
copyvideocodelicense_key();
jQuery("#copyButtonlicense_key").text("Copied");
});
});
</script>
<script>
function copyvideocodelicense_key() {
var copyText = document.getElementById("copyClipboardVideolicense_key");
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
jQuery("#copied-success").fadeIn(800);
jQuery("#copied-success").fadeOut(800);
}
</script>