Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

change woocommerce download page

$
0
0

Replies: 0

Hi I have downloadable online store Create with woocommerce for online streaming and I want links of one of my product category do not show the user. So I Create my own download page and remove links in that. But the expire date not show correctly and all of them the same. How can I fix this problem and show the expire date correctly?

function downloads(){
global $wpdb;
$user_id = get_current_user_id();

check_order();
$html = “<table >
<tr>
<th>name</th>
<th>exprie data</th>
<th>file</th>
</tr>”;
$products = wc_get_products(array(
‘category’ => array(‘player’),
));
foreach ($products as $p) {
$html .= ‘<tr>
<td>’ . $p->get_name() . ‘</td>
<td>∞</td>
<td>’;
foreach ($p->get_downloads() as $d) {
$html .= ‘get_file() . ‘” class=”btn btn-outline-info” target=”_blank”><i class=”fa fa-download p-1″></i>download‘;
}
$html .= “</td>
</tr>”;
}

foreach (bbloomer_products_bought_by_curr_user() as $id){
$userp = wc_get_product($id);

$category = get_term_by( ‘slug’, ‘eduction’, ‘product_cat’ );
$date = new jDateTime();
$available_variations = $userp->get_available_variations();
$count = count($available_variations);
$variation_id=$available_variations[$count][‘variation_id’]; // Getting the variable id of just the 1st product. You can loop $available_variations to get info about each variation.
$variable_product1= new WC_Product_Variation( $variation_id );
$d_id = $userp->get_id();
$resualt = ($wpdb->get_results(“SELECT * FROM wp_woocommerce_downloadable_product_permissions WHERE user_id = $user_id AND product_id= ‘{$d_id}'”))[0];
$d_id = $userp->get_id();
if(!$resualt){

$resualt = ($wpdb->get_results(“SELECT * FROM wp_woocommerce_downloadable_product_permissions WHERE user_id = $user_id AND product_id= ‘{$d_id}'”))[0];
}
if (in_array($category->term_id,$userp->get_category_ids())) {
$html .= ‘<tr>
<td>’ . $userp->get_name() . ‘</td>
<td>’.$date->date(“l j F Y”,strtotime($resualt->access_expires)).'</td>
<td>you can not download this‘;
$html .= “</td>
</tr>”;
} else {
$html .= ‘<tr>
<td>’ . $userp->get_name() . ‘</td>
<td>’.$date->date(“l j F Y”,strtotime($resualt->access_expires)).'</td>
<td>’;
$available_variations = $userp->get_available_variations();
$count = count($available_variations)-1;
$variation_id=$available_variations[$count][‘variation_id’]; // Getting the variable id of just the 1st product. You can loop $available_variations to get info about each variation.
$variable_product1= new WC_Product_Variation( $variation_id );
$date = new jDateTime();
$html .= “<div class=\”d-flex flex-column\”>”;

foreach ($variable_product1->downloads as $d) {
$html .= ‘<div class=”p-2″>’.$d->get_name().’get_file() . ‘” class=”btn btn-outline-info mr-4″ target=”_blank”><i class=”fa fa-download p-1″></i>دانلود</div>’;
}
$html .= “</div></td>
</tr>”;
}
}
$html .= “</table>”;
echo($html);
}

add_action( ‘woocommerce_account_downloads_endpoint’, ‘downloads’ );


Viewing all articles
Browse latest Browse all 59525

Trending Articles