コード例 #1
0
function foxyshop_featured_category($categoryName, $showAddToCart = false, $showMoreDetails = false, $showMax = -1, $simpleList = false)
{
    global $product;
    $term = get_term_by('slug', $categoryName, "foxyshop_categories");
    $currentCategorySlug = $term->slug;
    $currentCategoryID = $term->term_id;
    $args = array('post_type' => 'foxyshop_product', "foxyshop_categories" => $currentCategorySlug, 'numberposts' => $showMax);
    $args = array_merge($args, foxyshop_sort_order_array());
    $args = array_merge($args, foxyshop_hide_children_array($currentCategoryID));
    echo '<ul class="foxyshop_featured_product_list' . ($simpleList ? "_simple" : "") . '">';
    $featuredlist = get_posts($args);
    foreach ($featuredlist as $featuredprod) {
        $product = foxyshop_setup_product($featuredprod);
        if ($product['hide_product']) {
            continue;
        }
        if ($simpleList) {
            $simplewrite = '<li><a href="' . $product['url'] . '">' . apply_filters('the_title', $product['name']) . '</a></li>' . "\n";
            echo apply_filters("foxyshop_featured_category_simple", $simplewrite, $product);
        } else {
            $thumbnailSRC = foxyshop_get_main_image("thumbnail");
            $write = '<li class="foxyshop_product_box">' . "\n";
            $write .= '<div class="foxyshop_product_image">';
            $write .= '<a href="' . $product['url'] . '"><img src="' . $thumbnailSRC . '" alt="' . esc_attr($product['name']) . '" class="foxyshop_main_image" /></a>';
            $write .= "</div>\n";
            $write .= '<div class="foxyshop_product_info">';
            $write .= '<h2><a href="' . $product['url'] . '">' . apply_filters('the_title', $product['name']) . '</a></h2>';
            $write .= foxyshop_price(0, 0);
            if ($showMoreDetails) {
                $write .= '<a href="' . $product['url'] . '" class="foxyshop_button">' . __('More Details') . '</a>';
            }
            if ($showAddToCart) {
                $write .= '<a href="' . foxyshop_product_link("", true) . '" class="foxyshop_button">' . __('Add To Cart') . '</a>';
            }
            $write .= "</div>\n";
            $write .= '<div class="clr"></div>';
            $write .= "</li>\n";
            echo apply_filters("foxyshop_featured_category_html", $write, $product);
        }
    }
    echo "</ul><div class=\"clr\"></div>\n";
}
コード例 #2
0
function foxyshop_productlink_shortcode($atts, $content = null)
{
    global $product;
    $original_product = $product;
    extract(shortcode_atts(array("name" => '', "variations" => '', "quantity" => '1'), $atts));
    $prod = foxyshop_get_product_by_name($name);
    if (!$prod || !$name) {
        return "";
    }
    $product = foxyshop_setup_product($prod);
    $write = foxyshop_product_link("", true, $variations, $quantity);
    $product = $original_product;
    return $write;
}
コード例 #3
0
function foxyshop_product_details_setup()
{
    global $post, $foxyshop_settings;
    $_price = number_format((double) get_post_meta($post->ID, '_price', TRUE), FOXYSHOP_DECIMAL_PLACES, ".", ",");
    $_code = get_post_meta($post->ID, '_code', TRUE);
    $_category = get_post_meta($post->ID, '_category', TRUE);
    $_quantity_min = get_post_meta($post->ID, '_quantity_min', TRUE);
    $_quantity_max = get_post_meta($post->ID, '_quantity_max', TRUE);
    $_quantity_hide = get_post_meta($post->ID, '_quantity_hide', TRUE);
    $defaultweight = explode(" ", $foxyshop_settings['default_weight']);
    $defaultweight1 = (int) $defaultweight[0];
    $defaultweight2 = count($defaultweight) > 1 ? number_format($defaultweight[1], 1) : "0.0";
    $original_weight = get_post_meta($post->ID, '_weight', 1);
    if (!$original_weight && strpos($_SERVER['SCRIPT_FILENAME'], "post-new.php") === false) {
        $disable_weight_checked = ' checked="checked"';
        $_weight = array("", "");
    } else {
        $_weight = explode(" ", $original_weight);
        if (!$original_weight) {
            $_weight = array($defaultweight1, $defaultweight2);
        }
        $disable_weight_checked = "";
        if ((int) $_weight[0] == 0 && (double) $_weight[1] == 0) {
            if ($defaultweight1 == 0 && $defaultweight2 == 0.0) {
                $disable_weight_checked = ' checked="checked"';
                $_weight[0] = "";
                $_weight[1] = "";
            } else {
                $_weight[0] = $defaultweight1;
                $_weight[1] = $defaultweight2;
            }
        } else {
            $_weight[0] = (int) $_weight[0];
            if (!isset($_weight[1])) {
                $_weight[1] = 0;
            }
            $_weight[1] = number_format($_weight[1], 1);
        }
    }
    if ($foxyshop_settings['downloadables_sync'] && version_compare($foxyshop_settings['version'], '0.7.2', ">=") && $foxyshop_settings['domain']) {
        $show_downloadables = 1;
    } else {
        $show_downloadables = 0;
    }
    $_hide_product = get_post_meta($post->ID, '_hide_product', TRUE);
    ?>
	<?php 
    if ($show_downloadables) {
        ?>
	<a href="#" id="show_downloadable_list" title="<?php 
        _e('Show Available Downloadables', 'foxyshop');
        ?>
">"<?php 
        _e('Show Available Downloadables', 'foxyshop');
        ?>
</a>
	<div class="foxyshop_field_control" id="downloadable_list_parent">
		<a href="#" id="hide_downloadable_list" title="<?php 
        _e('Hide Available Downloadables', 'foxyshop');
        ?>
"><?php 
        _e('Hide Available Downloadables', 'foxyshop');
        ?>
</a>
		<label for="downloadable_list" style="width:100%;"><?php 
        _e('Select Downloadable To Prefill Data', 'foxyshop');
        ?>
</label>
		<select name="downloadable_list" id="downloadable_list">
			<?php 
        foxyshop_get_downloadable_list();
        $downloadable_list = get_option("foxyshop_downloadables");
        if (!is_array($downloadable_list)) {
            $downloadable_list = array();
            echo '<option value="">' . __('None Found') . '</option>' . "\n";
        } else {
            echo '<option value="">- - ' . __('Select Below', 'foxyshop') . ' - -</option>' . "\n";
        }
        foreach ($downloadable_list as $downloadable) {
            echo '<option value="' . esc_attr($downloadable['product_code']) . '"';
            echo ' category_code="' . esc_attr($downloadable['category_code']) . '"';
            echo ' product_price="' . esc_attr($downloadable['product_price']) . '"';
            echo '>' . esc_attr($downloadable['product_name']) . '</option>';
            echo "\n";
        }
        ?>
		</select>
		<a href="#" id="ajax_get_downloadable_list" title="<?php 
        _e('Refresh List', 'foxyshop');
        ?>
"><?php 
        _e('Refresh List', 'foxyshop');
        ?>
</a>
		<div style="clear:both"></div>
	</div>
	<?php 
    }
    ?>
	<div id="foxyshop_price" class="foxyshop_field_control">
		<label for="_price"><?php 
    _e('Base Price', 'foxyshop');
    ?>
</label>
		<input type="text" name="_price" id="_price" value="<?php 
    echo $_price;
    ?>
" onblur="foxyshop_check_number(this);" style="width: 90px; float: left;" />
		<span style="float: left; margin: 9px 0 0 5px;">0.00</span>
	</div>
	<div id="foxyshop_item_code" class="foxyshop_field_control">
		<label for="_code"><?php 
    _e('Item Code', 'foxyshop');
    ?>
</label>
		<input type="text" name="_code" id="_code" value="<?php 
    echo $_code;
    ?>
" />
	</div>
	<div id="foxyshop_weight" class="foxyshop_field_control">
		<label for="_weight1"><?php 
    _e('Weight', 'foxyshop');
    ?>
</label>
		<input type="text" name="_weight1" id="_weight1" value="<?php 
    echo $_weight[0];
    ?>
"<?php 
    if ($disable_weight_checked) {
        echo ' disabled="disabled"';
    }
    ?>
 />
		<span style="float: left; margin: 9px 0 0 5px; width: 21px;"><?php 
    echo $foxyshop_settings['weight_type'] == "metric" ? 'kg' : 'lbs';
    ?>
</span>
		<input type="text" name="_weight2" id="_weight2" value="<?php 
    echo $_weight[1];
    ?>
"<?php 
    if ($disable_weight_checked) {
        echo ' disabled="disabled"';
    }
    ?>
 />
		<span style="float: left; margin: 9px 0 0 5px; width: 23px;"><?php 
    echo $foxyshop_settings['weight_type'] == "metric" ? 'gm' : 'oz';
    ?>
</span>
		<input type="checkbox" name="weight_disable" id="weight_disable" title="<?php 
    _e('Disable Weight', 'foxyshop');
    ?>
" style="float: left; margin-top: 7px;"<?php 
    echo $disable_weight_checked;
    ?>
 />
		<label id="weight_disable_label" for="weight_disable" style="float: left; margin: 6px 0 0 2px; width: 16px;" title="<?php 
    _e('Disable Weight', 'foxyshop');
    ?>
" class="iconsprite <?php 
    echo $disable_weight_checked ? "hide_color" : "hide_gray";
    ?>
"></label>
	</div>
	<div id="foxyshop_quantity" class="foxyshop_field_control">
		<label for="_quantity_min"><?php 
    _e('Qty Settings', 'foxyshop');
    ?>
</label>
		<input type="text" name="_quantity_min" id="_quantity_min" value="<?php 
    echo $_quantity_min;
    ?>
" title="<?php 
    _e('Minimum Quantity', 'foxyshop');
    ?>
" style="width: 33px; float: left;" onblur="foxyshop_check_number_single(this);"<?php 
    if ($_quantity_hide) {
        echo ' disabled="disabled"';
    }
    ?>
 />
		<span id="quantity_min_label" style="float: left; margin: 6px 0 0 1px; width: 26px;" class="iconsprite <?php 
    echo $_quantity_min ? "down_color" : "down_gray";
    ?>
"></span>
		<input type="text" name="_quantity_max" id="_quantity_max" value="<?php 
    echo $_quantity_max;
    ?>
" title="<?php 
    _e('Maximum Quantity', 'foxyshop');
    ?>
" style="width: 33px; float: left;" onblur="foxyshop_check_number_single(this);"<?php 
    if ($_quantity_hide) {
        echo ' disabled="disabled"';
    }
    ?>
 />
		<span id="quantity_max_label" style="float: left; margin: 6px 0 0 1px; width: 26px;" class="iconsprite <?php 
    echo $_quantity_max ? "up_color" : "up_gray";
    ?>
"></span>
		<input type="checkbox" name="_quantity_hide" id="_quantity_hide" title="<?php 
    _e('Hide Quantity Box', 'foxyshop');
    ?>
" style="float: left; margin-top: 7px;"<?php 
    echo checked($_quantity_hide, "on");
    ?>
 />
		<label id="quantity_hide_label" for="_quantity_hide" style="float: left; margin: 6px 0 0 2px; width: 16px;" title="<?php 
    _e('Hide Quantity Box', 'foxyshop');
    ?>
" class="iconsprite <?php 
    echo $_quantity_hide ? "hide_color" : "hide_gray";
    ?>
"></label>
		<div style="clear:both"></div>
	</div>

	<?php 
    if (version_compare($foxyshop_settings['version'], '0.7.2', ">=") && $foxyshop_settings['domain']) {
        ?>
	<div id="foxyshop_category" class="foxyshop_field_control">
		<label for="_category" style="width: 100%;">
			<?php 
        _e('FoxyCart Category');
        ?>
			<small>(<a href="#" id="ajax_get_category_list_select" title="<?php 
        _e('Refresh List', 'foxyshop');
        ?>
"><?php 
        _e('Refresh List', 'foxyshop');
        ?>
</a>)</small>
		</label>
		<select name="_category" id="_category">
			<?php 
        if (strpos($foxyshop_settings['ship_categories'], "DEFAULT") === false) {
            $foxyshop_settings['ship_categories'] = "DEFAULT|" . __('Default for all products', 'foxyshop') . "\n" . $foxyshop_settings['ship_categories'];
        }
        $arrShipCategories = preg_split("/(\r\n|\n|\r)/", $foxyshop_settings['ship_categories']);
        for ($i = 0; $i < count($arrShipCategories); $i++) {
            if ($arrShipCategories[$i] == "") {
                continue;
            }
            $shipping_category = explode("|", $arrShipCategories[$i]);
            $shipping_category_code = trim($shipping_category[0]);
            if ($shipping_category_code == "DEFAULT") {
                $shipping_category_code = "";
            }
            $shipping_category_name = $shipping_category_code;
            $shipping_category_type = '';
            if (isset($shipping_category[1])) {
                $shipping_category_name = trim($shipping_category[1]);
            }
            if (isset($shipping_category[2])) {
                $shipping_category_type = trim($shipping_category[2]);
            }
            echo '<option value="' . esc_attr($shipping_category_code) . '"';
            if ($shipping_category_type) {
                echo ' rel="' . esc_attr($shipping_category_type) . '"';
            }
            if (esc_attr($shipping_category_code == $_category)) {
                echo ' selected="selected"';
            }
            echo '>' . esc_attr($shipping_category_name) . '</option>';
            echo "\n";
        }
        ?>
		</select>
	</div>
	<?php 
    } else {
        ?>
	<div id="foxyshop_category" class="foxyshop_field_control">
		<label for="_category" style="width:76px; margin-right: 4px;"><?php 
        _e('FoxyCart Cat');
        ?>
</label>
		<select name="_category" id="_category">
			<?php 
        if (strpos($foxyshop_settings['ship_categories'], "DEFAULT") === false) {
            $foxyshop_settings['ship_categories'] = "DEFAULT|" . __('Default for all products', 'foxyshop') . "\n" . $foxyshop_settings['ship_categories'];
        }
        $arrShipCategories = preg_split("/(\r\n|\n|\r)/", $foxyshop_settings['ship_categories']);
        for ($i = 0; $i < count($arrShipCategories); $i++) {
            if ($arrShipCategories[$i] == "") {
                continue;
            }
            $shipping_category = explode("|", $arrShipCategories[$i]);
            $shipping_category_code = trim($shipping_category[0]);
            if ($shipping_category_code == "DEFAULT") {
                $shipping_category_code = "";
            }
            $shipping_category_name = $shipping_category_code;
            $shipping_category_type = '';
            if (isset($shipping_category[1])) {
                $shipping_category_name = trim($shipping_category[1]);
            }
            if (isset($shipping_category[2])) {
                $shipping_category_type = trim($shipping_category[2]);
            }
            echo '<option value="' . esc_attr($shipping_category_code) . '"';
            if ($shipping_category_type) {
                echo ' rel="' . esc_attr($shipping_category_type) . '"';
            }
            if (esc_attr($shipping_category_code == $_category)) {
                echo ' selected="selected"';
            }
            echo '>' . esc_attr($shipping_category_name) . '</option>';
            echo "\n";
        }
        ?>
		</select>
	</div>
	<?php 
    }
    ?>

	<?php 
    if ($foxyshop_settings['show_add_to_cart_link'] && isset($_REQUEST['post'])) {
        global $product;
        $product = foxyshop_setup_product();
        ?>
	<div id="foxyshop_add_to_cart_link" class="foxyshop_field_control">
		<label for="add_to_cart_link"><?php 
        _e('Add to Cart', 'foxyshop');
        ?>
</label>
		<input type="text" name="add_to_cart_link" id="add_to_cart_link" value="<?php 
        echo foxyshop_product_link("", 1);
        ?>
" onclick="this.select();" readonly="readonly" />
	</div>
	<?php 
    }
    ?>

	<?php 
    if ($foxyshop_settings['enable_sso'] && $foxyshop_settings['sso_account_required'] == 2) {
        ?>
	<div id="foxyshop_require_sso" class="foxyshop_field_control">
		<input type="checkbox" name="_require_sso" id="_require_sso" style="float: left; margin: 5px 0 0 10px;"<?php 
        echo checked(get_post_meta($post->ID, '_require_sso', TRUE), "on");
        ?>
 />
		<label style="width: 210px;" for="_require_sso"><?php 
        _e('Require Account For Checkout', 'foxyshop');
        ?>
</label>
	</div>
	<?php 
    }
    ?>
	<div id="foxyshop_hide_product" class="foxyshop_field_control">
		<input type="checkbox" name="_hide_product" id="_hide_product"<?php 
    echo checked($_hide_product, "on");
    ?>
 />
		<label style="width: 210px;" for="_hide_product"><?php 
    echo sprintf(__('Hide This %s From List View', 'foxyshop'), FOXYSHOP_PRODUCT_NAME_SINGULAR);
    ?>
</label>
	</div>
	<div style="clear:both"></div>

	<script type="text/javascript">

	//Setup Vars For Use Later
	var FOXYSHOP_PRODUCT_NAME_SINGULAR = '<?php 
    echo strtolower(str_replace("'", "\\'", FOXYSHOP_PRODUCT_NAME_SINGULAR));
    ?>
';
	var show_downloadables = <?php 
    echo $show_downloadables ? 1 : 0;
    ?>
;
	var nonce_downloadable_list = '<?php 
    echo wp_create_nonce("foxyshop-ajax-get-downloadable-list");
    ?>
';
	var defaultweight1 = '<?php 
    echo $defaultweight1;
    ?>
';
	var defaultweight2 = '<?php 
    echo $defaultweight2;
    ?>
';
	var weight_dividend = <?php 
    echo $foxyshop_settings['weight_type'] == 'metric' ? 1000 : 16;
    ?>
;
	var use_chozen = <?php 
    echo $foxyshop_settings['related_products_custom'] || $foxyshop_settings['related_products_tags'] || $foxyshop_settings['enable_addon_products'] ? 1 : 0;
    ?>
;

	var renameLive = false;
	var post_id = <?php 
    echo $post->ID;
    ?>
;
	var nonce_images = '<?php 
    echo wp_create_nonce("foxyshop-product-image-functions-" . $post->ID);
    ?>
';

	<?php 
    //Get Max Upload Limit
    $max_upload = (int) ini_get('upload_max_filesize');
    $max_post = (int) ini_get('post_max_size');
    $memory_limit = (int) ini_get('memory_limit');
    $upload_mb = min($max_upload, $max_post, $memory_limit);
    $foxyshop_max_upload = $upload_mb * 1048576;
    if ($foxyshop_max_upload == 0) {
        $foxyshop_max_upload = "8000000";
    }
    ?>
	var foxyshop_max_upload = '<?php 
    echo $foxyshop_max_upload;
    ?>
';

	var FOXYSHOP_DIR = '<?php 
    echo FOXYSHOP_DIR;
    ?>
';
	var FOXYSHOP_URL_BASE = '<?php 
    echo FOXYSHOP_URL_BASE;
    ?>
';
	var bloginfo_url = '<?php 
    echo is_ssl() ? str_replace("http://", "https://", get_bloginfo("url")) : get_bloginfo("url");
    ?>
';
	var datafeed_url_key = '<?php 
    echo $foxyshop_settings['datafeed_url_key'];
    ?>
';

	</script>

	<?php 
    //Add Action For Product Details (For Other Integrations)
    do_action("foxyshop_admin_product_details", $post->ID);
    //Setup Hidden Admin Fields
    echo '<input type="hidden" name="products_meta_noncename" value="' . wp_create_nonce(__FILE__) . '" />';
    echo '<input type="hidden" name="menu_order" value="' . ($post->menu_order == 0 && $post->post_status == "auto-draft" ? $post->ID : $post->menu_order) . '" />';
}