product

how to get product attributes from wordpress database

雨燕双飞 提交于 2019-12-18 12:09:00
问题 Writing custom code to create product detail page with wordpress database. I have displayed product title, desc, price, stock, etc and got stuck up with product attributes. In the database, _product_attributes is stored in serialized manner in wp_postmeta table in database. And i couldn't unserailize attributes from it. But i found, each attribute value with it own price has been stored in wp_postmeta in some other post_id. for example, product with post_id=55 has attribute name 'Size value'

Replace product zero displayed price with a custom text in Woocommerce 3

家住魔仙堡 提交于 2019-12-18 09:25:56
问题 I am looking for a way to replace €0,00 price for a WooCommerce (version 3.3.x) product with text, like 'Based on contract'. Preferably visible in the webshop and emails. Because of recent changes in WooCommerce the existing snippets aren't working anymore, like: add_filter('woocommerce_get_price_html', 'changeFreePriceNotice', 10, 2); function changeFreePriceNotice($price, $product) { if ( $price == wc_price( 0.00 ) ) return 'FREE'; else return $price; } Or <?php // Do not copy the opening <

Replace product zero displayed price with a custom text in Woocommerce 3

久未见 提交于 2019-12-18 09:25:11
问题 I am looking for a way to replace €0,00 price for a WooCommerce (version 3.3.x) product with text, like 'Based on contract'. Preferably visible in the webshop and emails. Because of recent changes in WooCommerce the existing snippets aren't working anymore, like: add_filter('woocommerce_get_price_html', 'changeFreePriceNotice', 10, 2); function changeFreePriceNotice($price, $product) { if ( $price == wc_price( 0.00 ) ) return 'FREE'; else return $price; } Or <?php // Do not copy the opening <

Targeting product terms from a custom taxonomy in WooCommerce

老子叫甜甜 提交于 2019-12-18 09:17:11
问题 I use some custom taxonomies in my website… movies_type (is one of them) and has 4 terms: movie , tvseries , concert-and-ceremony, documentary I have tagged Every product with just one of this terms. How can I target those products that have the same term? Thanks 回答1: You can use has_term() WordPress function to target your products with terms from a custom taxonomy , just as for product categories which custom taxonomy is "product_cat" For example, you can use it this way: if ( has_term(

WooCommerce - Adding a custom price to each product in cart

夙愿已清 提交于 2019-12-18 09:05:15
问题 I would like to update the price of products adding a custom price in cart using this simple piece of code update_post_meta( $product->id, '_regular_price', $frame_price_added); . Note: what I'm trying to achieve is to add this custom price to each product in cart. I have try to get $frame_price_added this way: $frame_price = $res['_number_field'][0]; $frame_price_added = $product->price + $frame_price; Here $product->price is price coming from woocomerce product and $frame_price is coming

How can I calculate (A*B)%C for A,B,C <= 10^18, in C++?

半腔热情 提交于 2019-12-18 06:19:49
问题 For example, A=10^17, B=10^17, C=10^18. The product A*B exceeds the limit of long long int. Also, writing ((A%C)*(B%C))%C doesn't help. 回答1: Assuming you want to stay within 64-bit integer operations, you can use binary long division, which boils down to a bunch of adds and multiply by two operations. This means you also need overflow-proof versions of those operators, but those are relatively simple. Here is some Java code that assumes A and B are already positive and less than M. If not, it

Set product custom field and display value in cart, checkout and view order

穿精又带淫゛_ 提交于 2019-12-18 04:55:17
问题 I've created a custom field for warranty in my products pages, via function.php. add_action( 'woocommerce_product_options_general_product_data', 'test_custom_fields' ); function test_custom_fields() { // Print a custom text field woocommerce_wp_text_input( array( 'id' => '_warranty', 'label' => 'i.e. 15 years', 'description' => '', 'desc_tip' => 'true', 'placeholder' => 'i.e. 15 years' ) ); } add_action( 'woocommerce_process_product_meta', 'test_save_custom_fields' ); function test_save

Add a product custom field to Admin product bulk edit form in WooCommerce

好久不见. 提交于 2019-12-18 04:26:10
问题 I have added a custom field in my WooCommerce products like in this question/answer: Display a custom product field before short description in WooCommerce. Is it possible to add this custom field to the product bulk edit special page (accessible from Admin products list page) ? 回答1: Yes it's possible to bulk edit products for your custom field '_text_field' (as in your linked question/answer) . You can add this custom field at the beginning or at the end of edit page. For the beginning you

How to update custom options programatically in magento?

百般思念 提交于 2019-12-18 03:47:05
问题 I have lot of products with custom options, now I have requirement to update only custom options through csv file. so how we can do this programatically? 回答1: I think this is also useful... If you are customize the products . <?php $magePath = 'app/Mage.php'; require_once $magePath; Varien_Profiler::enable(); Mage::setIsDeveloperMode(true); ini_set('display_errors', 1); umask(0); Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $product_ids = array(1,2,167); $productmodel =

Override External Product URL to “Add to Cart” product button

别等时光非礼了梦想. 提交于 2019-12-17 22:29:01
问题 I work on site that use External products from Amazon, but want instead pointing users to that external URL, first to add to cart that product. I have this function, that change Default Button text for each product, to Add to cart. function sv_wc_external_product_button( $button_text, $product ) { if ( 'external' === $product->get_type() ) { // enter the default text for external products return $product->button_text ? $product->button_text : 'Add To Cart'; } return $button_text; } add_filter