product

Default attribute value for all product in magento

孤街醉人 提交于 2020-01-10 03:16:31
问题 I want to set a default value of an attribute for all product. 回答1: I had same problem before,when i added 11096 product(downloadable products) in my store then client told me to add new attributes in product so i create 1 attribute (Type is Yes/No) and set to attribute set. Now my problem is how can i edit all product and set that attribute yes or not.if i not set then value is null so i wrote few line code. Please check this code may be it'll helpful to you. $ProductId = Mage:

Google Foobar challenge failing 2 out of 5 test cases

旧城冷巷雨未停 提交于 2020-01-07 08:54:26
问题 I am doing the Google Foobar challenge power_hungry (see below). I cannot figure out why the following code fails test cases #3 and #5. Can anyone see what I'm missing? Have I failed to consider an edge case? Here is my Python code: from functools import reduce import operator def get_pair_prod(xs): if len(xs) < 2: return 1 xs.sort() return xs[0] * xs[1] def answer(xs): if len(xs) == 0: return "0" positive = [x for x in xs if x > 0] negative = [x for x in xs if x < 0] if len(negative) == 1

Moving variable product dropdowns in WooCommerce

北城以北 提交于 2020-01-06 05:30:12
问题 I've been playing around with hooks for a few hours and couldn't find the solution so far. I am trying to move the variable product dropdown next to the quantity / add to cart button, but I don't know how to achieve this. Here is the current render : So the display would go like : Product title Price area Attribute dropdown / Quantity / Add to cart Edit : I have removed the price range. In the following code I change the live price behavior : add_filter( 'woocommerce_variable_price_html',

Save an empty value from a custom Text field in WooCommerce

余生颓废 提交于 2020-01-05 08:27:35
问题 I am working on a WordPress eCommerce website, with WooCommerce being the chosen Shopping Platform. I have created a Custom Field, within the WooCommerce Product Dashboard by inserting the following code into the functions.php file: function product_custom_fields_add(){ echo '<div class="product_custom_field">'; // Minimum Required Custom Letters woocommerce_wp_text_input( array( 'id' => '_minimum_engrave_text_option', 'name' => '_minimum_engrave_text_option', 'desc' => __('set custom minimum

Display only the first and last term of taxonomy for a product

房东的猫 提交于 2020-01-04 01:52:08
问题 I have a custom taxonomy (Year) and each year is a term. Some times a film has more than one year. I need to print only the (first - Last) year no all year from one film. For example I have this years for Vampire diaries: 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 and 2016 I would like to only display the first and Last years this way: Vampire diaries (2008 - 2016) My code is: <?php $releaseyear_as_text = get_the_term_list( $post->ID,'release-year','', ' , ' ); ?> <h1><a href="<?php the

Get products which are visible in catalog in a WP_query on Woocommerce

若如初见. 提交于 2020-01-03 19:25:45
问题 I'm currently trying to get all products in a category page which are visible in catalog. I've tried this here but I'm getting no products with this query: $args = array( 'post_type' => 'product', 'product_cat' => get_queried_object()->slug, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array( 'catalog', 'visible' ), 'compare' => 'IN', ) ) ); $loop = new WP_Query( $args ); var_dump( $loop ); When I remove the meta_query visibility part I'm getting all products including the

Get products which are visible in catalog in a WP_query on Woocommerce

[亡魂溺海] 提交于 2020-01-03 19:24:20
问题 I'm currently trying to get all products in a category page which are visible in catalog. I've tried this here but I'm getting no products with this query: $args = array( 'post_type' => 'product', 'product_cat' => get_queried_object()->slug, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array( 'catalog', 'visible' ), 'compare' => 'IN', ) ) ); $loop = new WP_Query( $args ); var_dump( $loop ); When I remove the meta_query visibility part I'm getting all products including the

Show All Color Variants on Collection page in Shopify using Brooklyn Theme

余生颓废 提交于 2020-01-03 16:53:11
问题 Hey i am using brooklyn theme in my shopify website. I have different products will color variants . When i click on collection page i want to show all color variants of that products as separate products. I am googling since last night any help please. 回答1: Look at the codes below. <ul class="colorlist"> {% for option in product.options %} {% if option == 'Color' %} {% assign index = forloop.index0 %} {% assign colorlist = '' %} {% assign color = '' %} {% for variant in product.variants %} {

Display a custom message when a product is not purchassable in Woocommerce single pages

自作多情 提交于 2020-01-03 05:20:09
问题 I am creating a website which is flower shop. Some flowers are seasonally available. Using Advanced Custom Fields plugin, I have added a custom field in Woocommerce product post type (check box) list of months to chose from in which product will be available. I have been able to disable the add to cart button for the months in which product will not be available using code below: add_filter('woocommerce_is_purchasable', 'is_available', 10, 2); function is_available() { // this is a field

How do display products by category id in template page(.phtml page) in magento?

帅比萌擦擦* 提交于 2020-01-03 03:36:27
问题 i am new to magento. i used below code in allproduct.phtml file for get all category id's. function get_categories(){ $category = Mage::getModel('catalog/category'); $tree = $category->getTreeModel(); $tree->load(); $ids = $tree->getCollection()->getAllIds(); $arr = array(); if ($ids){ foreach ($ids as $id){ $cat = Mage::getModel('catalog/category'); $cat->load($id); $arr[$id] = $cat->getName(); } } return $arr; } now i got category Id'd like below in one array, Array ( [Root Catalog] => 1