Пример #1
0
//$post_code = strtoupper( trim( $_POST['code_' . $shortcode_id] ) );
/* get matching code record from database to check if code is valid */
$wpdb->show_errors();
$code = $wpdb->get_row($wpdb->prepare("SELECT ID, `release` FROM " . dc_tbl_codes() . " WHERE CONCAT(code_prefix, code_suffix) = %s", array($post_code)));
if ($code->ID) {
    /* get release details */
    $release = $wpdb->get_row("SELECT * FROM " . dc_tbl_releases() . " WHERE ID = " . $code->release);
    /* get number of downloads with this code */
    $downloads = $wpdb->get_row($wpdb->prepare("SELECT COUNT(*) AS downloads FROM " . dc_tbl_downloads() . " WHERE code=(SELECT ID FROM " . dc_tbl_codes() . " WHERE CONCAT(code_prefix, code_suffix) = %s )", array($post_code)));
    /* check if maximum of allowed downloads is reached */
    if ($downloads->downloads < $release->allowed_downloads) {
        /* set temporary download lease ID */
        $lease_ID = md5('wp-dl-hash' . $code->ID);
        /* generate html code for download form */
        $sku = $release->title;
        $product_ID = get_product_id_by_sku($sku);
        $artists = array();
        $data = get_field('product-artists', $product_ID);
        foreach ($data as $d) {
            $artists[] = get_the_title($d->ID);
        }
        $artist = implode(" & ", $artists);
        $title = get_release_attribute_value($product_ID, 'release-title');
        $url = get_stylesheet_directory_uri() . "/download/download.php";
        $return['download_form'] = "<form id=\"ac-download-form\" name=\"ac-download-form\" action=\"" . $url . "\" method=\"GET\"> \n" . "<input type=\"hidden\" name=\"lease\" value=\"" . $lease_ID . "\" /> \n" . "<div class='title'>" . $sku . " | " . $artist . " - " . $title . "</div> \n" . get_the_post_thumbnail($product_ID, "download-thumb") . "\n" . "<a id=\"ac-download-submit\" class=\"submit\" href=\"javascript:void(0)\" onclick=\"dlFormSubmit()\"><span>Download</span></a>" . "</form>";
    } else {
        $return['error_message'] = "Sorry, that code has already been used.";
    }
} else {
    $return['error_message'] = "Sorry, that code doesn't exist.";
}
Пример #2
0
    function widget($args, $instance)
    {
        extract($args);
        ?>
		
		<div class="last-releases-widget">
			<header class="entry-header"><h2><?php 
        echo $instance['title'];
        ?>
</h2></header>
			<hr class='small-line' />
			
			<?php 
        /* get last 3 releases */
        $release_ct = 0;
        query_posts(array('post_type' => 'product', 'posts_per_page' => $this->max_releases * 2, 'product_cat' => '7inches,10inches,12inches,other,tape,digital'));
        while (have_posts()) {
            the_post();
            ?>
				<?php 
            /* skip non-orphane digital releases */
            $post_ID = get_the_ID();
            $sku = get_product_sku_by_id($post_ID);
            if (substr($sku, -1) == 'd') {
                if (!is_null(get_product_id_by_sku(substr($sku, 0, -1)))) {
                    continue;
                }
            }
            $release_ct++;
            /* set link */
            $external_link = get_field('release-external_buy_link');
            if (empty($external_link)) {
                $link = get_permalink($post_ID);
            } else {
                $link = '/shop#' . $post_ID;
            }
            /* check release count */
            if ($release_ct == $this->max_releases + 1) {
                break;
            }
            ?>
				<a href="<?php 
            echo $link;
            ?>
">
					<?php 
            echo the_post_thumbnail('last-releases-thumb');
            ?>
					<div class="details">
						<?php 
            $artists = array();
            $data = get_field('product-artists');
            foreach ($data as $d) {
                $artists[] = get_the_title($d->ID);
            }
            $title = get_release_attribute_value($post->ID, 'release-title');
            ?>
						<h3>
							<span class="artist"><?php 
            echo implode(" & ", $artists);
            ?>
</span><br />
							<?php 
            if (!empty($title)) {
                ?>
			        			<span class="title"><?php 
                echo $title;
                ?>
</span>
			        		<?php 
            } else {
                ?>
								&nbsp;        			
							<?php 
            }
            ?>
						</h3>
						<hr class="small-line" />
		        	</div>
	        	</a>
			<?php 
        }
        ?>
		</div><?php 
    }
Пример #3
0
post_class($classes);
?>
 id="shop-item-<?php 
echo $post_ID;
?>
">
	
	<?php 
$sku = $product->get_sku();
$external_link = false;
$is_digital = false;
$physical_product_ID = '';
if (strpos($sku, 'd')) {
    $is_digital = true;
    $sku = str_replace('d', '', $sku);
    $physical_product_ID = get_product_id_by_sku($sku);
    $link = get_permalink($physical_product_ID);
} else {
    $special_link = get_field('release-special_link');
    if (empty($special_link)) {
        $link = get_permalink($post_ID);
    } else {
        $link = $special_link;
        $external_link = true;
    }
}
$artists = array();
$data = get_field('product-artists');
foreach ($data as $d) {
    $artists[] = get_the_title($d->ID);
}
Пример #4
0
    }
    $tracklist .= "</p>";
} else {
    $tracklist = "<p>" . $tracklist . "</p>";
}
/* get release buyability */
$buy_txt = "<p>Go to <a href='/shop#" . $post->ID . "'>Shop</a></p>";
$in_stock = $product->get_stock_quantity() == 0 ? false : true;
$is_preorder = is_preorder($post->ID);
if ($is_preorder) {
    $buy_txt = "<p><a href='/shop#" . $post->ID . "'>PreOrder</a></p>";
} else {
    $format = get_release_attribute_value($post->ID, 'release-format');
    $format = strtok($format, " ");
    $buy_txt = "<p>" . $format . " = Sorry, sold out</p>";
    $digital_product_ID = get_product_id_by_sku($sku . "d");
    if (!empty($digital_product_ID)) {
        $buy_txt .= "<p><a href='/shop#" . $post->ID . "'>Digital</a></p>";
    }
}
/* get other informations */
$info = get_field('release-info');
$credits = get_field('release-credits');
$soundcloud_set = get_field('release-soundcloud_set');
?>
			
		<div class="sku">
			<?php 
echo $sku;
?>
		</div>