categories

Magento - show categories a product is in

不打扰是莪最后的温柔 提交于 2019-12-02 06:39:51
问题 I use the code below to show the categories that a product is in on my productpage. But i run multi-store with the same products and it is showing also the categories of the other websites. How can i only show the categories of the site that i'm visiting? <?php $categories = $_product->getCategoryIds(); ?> <?php foreach($categories as $k => $_category_id): ?> <?php $_category = Mage::getModel('catalog/category')->load($_category_id) ?> <a href="<?php echo $_category->getUrl() ?>"><?php echo $

Magento - show categories a product is in

末鹿安然 提交于 2019-12-02 05:31:25
I use the code below to show the categories that a product is in on my productpage. But i run multi-store with the same products and it is showing also the categories of the other websites. How can i only show the categories of the site that i'm visiting? <?php $categories = $_product->getCategoryIds(); ?> <?php foreach($categories as $k => $_category_id): ?> <?php $_category = Mage::getModel('catalog/category')->load($_category_id) ?> <a href="<?php echo $_category->getUrl() ?>"><?php echo $_category->getName() ?> | </a> <?php endforeach; ?> faizanbeg Check loaded category id is exist or not

Is there a way to get a category's name in lowercase?

无人久伴 提交于 2019-12-02 04:29:28
I am setting up a Wordpress theme and I'm integrating a facebook "Like" button into each of the categories. I need a way of getting the current page URL in lowercase so I can have several like buttons for all the categories while each having different url links. Currently, when I use <?php get_permalink( ); ?> or <?php the_permalink( ); ?> in the category template, it outputs the URL plus the permalink of the first post, which isn't what I want currently. I've tried using but it outputs the title with the first letter Capped. I need the category name in lowercase for the URL to be valid in

Automatically assign products to a defined product category in WooCommerce

徘徊边缘 提交于 2019-12-02 04:00:08
问题 In Woocommerce, I am trying to automatically assign a given product category to products if they have a specific custom field value (Using Advanced custom fields plugin to generate this field). In my functions.php I have : function auto_add_category ($product_id = 0) { if (!$product_id) return; $post_type = get_post_type($post_id); if ( "product" != $post_type ) return; $field = get_field("city"); if($field == "Cassis"){ $terms = get_the_terms( $post->ID, 'product_cat' ); foreach ($terms as

Cart discount for a product category based on quantity calculations

假装没事ソ 提交于 2019-12-02 02:14:11
I wan to add a function to woocommerce that will calculate a 10% discount when 12-23 items from one category is added to the cart. Then if 24 - 47 items of the category are added it would be a 15% discount. Last if 48+ items from this category are added it would be a 20% discount. actual code example would be awesome as I am new to woocommerce LoicTheAztec Updated — Corrected code mistakes and added enhancements in the outputted discount text Here is the function hooked in woocommerce_cart_calculate_fees hook that is going to make the discount for that particular category (or subcategory too)

Automatically assign products to a defined product category in WooCommerce

妖精的绣舞 提交于 2019-12-02 01:15:27
In Woocommerce, I am trying to automatically assign a given product category to products if they have a specific custom field value (Using Advanced custom fields plugin to generate this field). In my functions.php I have : function auto_add_category ($product_id = 0) { if (!$product_id) return; $post_type = get_post_type($post_id); if ( "product" != $post_type ) return; $field = get_field("city"); if($field == "Cassis"){ $terms = get_the_terms( $post->ID, 'product_cat' ); foreach ($terms as $term) { $product_cat_id = $term->term_id; if($product_cat_id != 93){ wp_set_post_terms( $product_id, 93

Get all categories of a custom post type

房东的猫 提交于 2019-12-01 23:27:59
问题 I am trying to get all categories of a custom post type.I am using get_the_category(); function to retrieve the categories.But if i have 3 posts with 1 category the category is repeated 3 times :o . My codes are <?php query_posts( array( 'post_type' => 'member', 'showposts' => 8 ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); $categories = get_the_category(); foreach ( $categories as $category ) { echo $category->name, ' '; } ?> <?php endwhile; endif; wp_reset_query(); ?> Is

Create barchart using jfreechart with bars of same category together

夙愿已清 提交于 2019-12-01 18:16:06
I want to make bar chart using jfreechart such that the bars which belong to the same category should be displayed adjacent without any gaps. The categories should be displayed with gaps. Also each category may have different number of bars. How it can be achived using Jfreechart library? Following image is the sample of what I require. Here all the bars of same category should be of same color and with no gap(or a very little gap). Thanks in advance, Abhinav I am aware of the age of this post. Anyway I am posting my solution, maybe someone else who will find himself here looking for the

Pandas: how to draw a bar plot with two categories and four series each?

自作多情 提交于 2019-12-01 18:14:59
I have the following dataframe, where pd.concat has been used to group the columns: a b C1 C2 C3 C4 C5 C6 C7 C8 0 15 37 17 10 8 11 19 86 1 39 84 11 5 5 13 9 11 2 10 20 30 51 74 62 56 58 3 88 2 1 3 9 6 0 17 4 17 17 32 24 91 45 63 48 Now I want to draw a bar plot where I only have two categories ( a and b ), and each category has four bars representing the average of each column. Columns C1 and C5 should have the same color, as should columns C2 and C6, and so forth. How can I do it with df.plot.bar()? The plot should resemble the following image. Sorry for it being hand-drawn but it was very

Create barchart using jfreechart with bars of same category together

女生的网名这么多〃 提交于 2019-12-01 17:19:52
问题 I want to make bar chart using jfreechart such that the bars which belong to the same category should be displayed adjacent without any gaps. The categories should be displayed with gaps. Also each category may have different number of bars. How it can be achived using Jfreechart library? Following image is the sample of what I require. Here all the bars of same category should be of same color and with no gap(or a very little gap). Thanks in advance, Abhinav 回答1: I am aware of the age of