本文整理汇总了PHP中WC_Product_Variation::get_files方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product_Variation::get_files方法的具体用法?PHP WC_Product_Variation::get_files怎么用?PHP WC_Product_Variation::get_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product_Variation
的用法示例。
在下文中一共展示了WC_Product_Variation::get_files方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_downloads
/**
* Get the downloads for a product or product variation
*
* @since 2.1
* @param WC_Product|WC_Product_Variation $product
* @return array
*/
private function get_downloads($product)
{
$downloads = array();
if ($product->is_downloadable()) {
foreach ($product->get_files() as $file_id => $file) {
$downloads[] = array('id' => $file_id, 'name' => $file['name'], 'file' => $file['file']);
}
}
return $downloads;
}
示例2: VALUES
$productPrice = $variation->get_price();
}
// If user has required ammount of credits then continue
if ($getUserCredit >= $productPrice) {
get_currentuserinfo();
// Save the purchase to the database and update credits balance of the user
$sql = $wpdb->query("UPDATE `" . $wpdb->prefix . "woocredit_users` SET credit = '" . ($getUserCredit - $productPrice) . "' where user_id=" . get_current_user_id());
$sql = $wpdb->query("INSERT INTO `" . $wpdb->prefix . "woocredit_products` (user_id, product_id, price) VALUES (" . get_current_user_id() . "," . $_POST['productid'] . "," . $productPrice . ")");
// If the product or variant are downloadable then send an email with a link to the files
if ($product && $product->is_downloadable() || $variation && $variation->is_downloadable()) {
$files = [];
if ($product && $product->is_downloadable()) {
$files = $product->get_files();
}
if ($variation && $variation->is_downloadable()) {
$files = $variation->get_files();
}
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$codingKey = $translate->getCodingKey();
$downloadHtml = "";
foreach ($files as $file) {
$downloadHtml .= '<a href="';
$downloadHtml .= get_site_url() . "/wp-content/plugins/simple-credits/download.php?action=email";
$downloadHtml .= "&time=" . $translate->encode(time(), $codingKey);
$downloadHtml .= "&filename=" . $translate->encode($file['file'], $codingKey);
$downloadHtml .= '">' . $file['name'] . '</a><br/>';
}
$email_text = str_replace("[filedownload]", $downloadHtml, $translate->wooTranslate('email', get_bloginfo('language')));
$message = '
<html>