Tag Info

New answers tagged

0

I did this to solve the problem <?php $terms = get_the_terms( $post->cat_ID , 'product_cat' ); foreach ($terms as $term) { $term_id = $term->term_id; $term_link = get_term_link( $term, $taxonomy ); $term_name = $term->name; echo '<a class="cat-box" href="' . $term_link . '"><span ...


0

Was able to resolve this by changing 'option' to 'options' and making the values of options an array, like this. 'attributes' => array( array( 'name' => 'Manufacturer', 'slug' => 'pa_manufacturer', 'options' => array('Sony') ) ...


0

I think you need a filter on posts_orderby to do this: add_filter( 'posts_orderby', function ( $orderby, $query ) { if ( $query->get( 'orderby' ) == 'zuk' ) { global $wpdb; //$field = $wpdb->posts . '.post_title'; $field = $wpdb->postmeta . '.meta_value'; $order = $query->get( 'order' ); $orderby = ...


0

I usually do this by getting data from database $result = mysql_query("SELECT * FROM wp_terms JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id WHERE wp_term_taxonomy.parent = ".$parent_cat_ID." AND wp_term_taxonomy.taxonomy = 'product_cat'");


0

If your naming system is consistent then simply ordering by the post name should do it: $args = array( 'orderby' => 'title', 'order' => 'ASC', ); $q = new WP_Query($args); var_dump($q->request); var_dump(wp_list_pluck($q->posts,'post_title')); Or, as a pre_get_posts filter (assuming the main query is what we want to alter): ...


1

Arrrrg a WooCommerce question... quick burn him at the stake! There's a couple of problems with your callback function above: you are not declaring global $woocommerce so you do not have access to the $woocommerce global variable. and $woocommerce->customer holds the state of the WC_Customer class however this class does not contain a get_role() ...


1

Try this - Add your button inside a form and write down script to add product to the cart and redirect user directly to the checkout page. Suppose, following is the button that you can put on single product page using a WooCommerce hook. <button name="checkout_now"> Checkout Now </button> PHP code: global $woocommerce; $post_id = ...


0

I don't know it's the best way to do or not, but it worked for me. add_filter('woocommerce_after_checkout_validation', 'additional_validation')); function additional_validation($fields) { // bypass all error returned wc_clear_notices(); }


0

It would be better if you can post some code for your use case, because I'm not really sure about the context here. Generally, your product must be a WC_Product_Variable object in order to retrive all variations information, the typical flow should be something like this: // create WC_Product_Variable product, assume $post is your WordPress post object ...


1

Technically speaking, Woocommerce products are just another WordPress post object with a customized post type (which is product in this case). If you take a look at the create_product function inside class-wc-api-products.php, you'll see this line: // Attempts to create the new product $id = wp_insert_post( $new_product, true ); So the API ends up using ...


0

In short, this is serialized data and this is how data is stored from a custom field (and many other datastrings) in the db. s:114 is auto generated and simply means that the value http://localhost/wp-content/uploads/woocommerce_uploads/2014/09/test-file.pdf is a string and is 114 characters long. This is used when the data is read and used. If the URL ...


-1

Eric based on your code I wrote to meet my needs, for those who want to follow: Eric com base em seu código eu escrevi o para atender as minhas necessidades, para quem quiser segue abaixo: <?php global $wpdb; $produto_id = 22777; // ID do produto $consulta = "SELECT order_id FROM {$wpdb->prefix}woocommerce_order_itemmeta woim LEFT JOIN ...


0

To check if product already exists, you need to fire query in database with product title as shown below : global $wpdb; $result = $wpdb->get_row("SELECT ID FROM wp_posts WHERE post_title = 'title' && post_status = 'publish' && post_type = 'product'"); if(empty($result)){ // product doesn't exists } else{ // product already ...


1

As per what I understood from your question, you want two things - Listing of all publisher Listing of all books of a particular publisher. Here is code for both. Listing of all publisher $terms = get_terms( 'pa_publisher' ); echo '<ul>'; foreach ($terms as $each_term) { echo '<li>'.$each_term->name.'</li>'; } echo ...


2

Do you really need to know the ID, for that see @PieterGoosens's answer, or do you just need to know if you are at the post type product archive? The latter can easily be achieved by using is_post_type_archive(): if ( is_post_type_archive( 'product' ) ) { // code }


2

If this is a true page, then you can get the ID of that specific page with get_queried_object_id(). This works and will return the ID on the specific pages, single, category, taxonomy, tag and author pages where it is used. True date and time archives and the homepage will not have ID's You can do the following $page_id = get_queried_object_id(); echo ...


0

I feel like this is close. Just not firing correctly. add_action( 'woocommerce_order_status_completed', 'gt_add_user_to_group' ); function gt_add_user_to_group( $order_id ) { $order = new WC_Order( $order_id ); $coupon_codes = $order->get_used_coupons(); // Returns array of coupon codes $user_id = $order->get_user_id(); $items = ...


1

Here was the problem. I just didn't add the <?php wp_footer(); ?> in my footer.php file. so simple but important. I guess woocommerce group should check if wp_footer() doesn't exists add the scripts in header instead because I have wp_head() set up in my header.php


0

WooCommerce provides what they term as Webhooks - This allows you to make API calls based on certain things happening in the store. The official docs are at http://docs.woothemes.com/document/webhooks/. They essentially send data to the provided URL when the event you choose is fired (so for you, once the order is paid for.


1

This will definitly remove word category . Add this code in functions.php.As you already know woocommerce_template_single_meta is the hook responsible for meta information of the single-product. File is present in /woocommerce/templates/single-product/meta.php. Either you can use the following code to edit the html of meta.php or you can copy the file ...


-1

Feito! Realmente com o WP_Query não dá... pra saber essa informação é necessário utilizar 2 tabelas do WooCommerce. Então montei a função pra você... ela busca pelo postID do produto e retorna o objeto dos pedidos pra você fazer o loop normal. É só coloca-la no seu function.php e usa-la em qualquer lugar que quiser! Aqui funcionou bem! Se algo der errado ...


0

I found a solution to my problem. What I did is the following: First I created a new page in Wordpress with the php that creates the product that has a link like: www.mypagename.com/myphpcode The php is the following: `global $woocommerce; $my_post = array( 'post_title' => 'My title', 'post_content' => 'This is my post.', 'post_status' ...


0

i am logically very much clear with this kings of function because i have made such function in woocommerce the operation is all about to integrate the big post shipping rates. but in your case you need to add_fee() function in woocommerce. the first things you need to get the market charge and add into your cost. i hope below code will helps. function ...


0

I solved this by passing the array of terms into a sorting function. The array is passed by reference so nothing needs to be returned: function sort_object_terms(&$terms) { global $wpdb; // First get an array of just the term IDs $term_ids = array_map(function($term) { return (int)$term->term_id; }, $terms); // Now get ...


-1

Doens't matter. I fixed it. It was because of the instructions listed here under "Messed Up Shortcodes" - http://docs.woothemes.com/document/woocommerce-shortcodes/


0

According to me, there is an issue with cookie/session. Check below steps for the same: 1) Add any item into cart, once you hit on add to cart button for any item. 2) Open second tab for same URL and check for add cart item count. You can see only one item added display but if you refresh the first one tab then you can see add to cart item count is now two ...


-1

There are many plugin provide these kind of functionality. You need to research for the same some plugin which can help you achieve you goal are as follows: WooCommerce Currency Switcher This Plugin allows you to switch to different currencies and get their rates converted in the real time WooCommerce Multilingual - run WooCommerce with WPML This plugin ...


0

Many Importing plugins have this functionality where the import are done periodically as set by the admin in settings. Some Import Plugins also provides facilities to upload products from a specific URL. In this approach you can just tell a Supplier to add his CSV in a server site where he will always update it whenever he has new products. The Import ...


6

An attachment is a Post The posts table contains information on the attachemnt post. In WordPress every uploaded media has it's own post entry, where post_type is 'attachment' and post_status is 'inherit'. In fact, you can get attachment post types using functions used to get other post types, like post, page or any CPT. That include WP_Query, ...


0

You can create product attributes for those.


1

First is showing the attachment file path, second is file attributes size, type, height, width etc. Thanks attachment in wp_post shows the attachment basic details title, time, author etc. wp_postmeta shows attachment all other details for example attachment would be text, pdf, image etc so it having different meta data for different types of posts. ...


1

Woocommerce stores 'order' metakeys in the table wp_woocommerce_termmeta. The mechanism it uses is the same as menu_order for posts. Check this thread for reference. Thanks


1

Your edit got me to this idea, there indeed is no function called »woocommerce«, there is a class »WooCommerce« though. One thing to be aware of is, that the check has to late enough, so that plug-ins are actually initialized, otherwise - obviously - the class won't exists and the check returns false. So your check should look like this: if ( class_exists( ...


0

By using hook remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_price',10); or CSS span.price { display: none !important; } *Tag May be different as per your theme. Thanks, Vee


0

You could try serializing the array so that it becomes a flattened textual representation of the values it contains. e.g. $testArr = [3,4,"test", 56]; echo serialize($testArr); gives: a:4:{i:0;i:3;i:1;i:4;i:2;s:4:"test";i:3;i:56;} However, you should probably consider using user sessions for this rather than cookies.


0

Nasir, you can inherit the woo-commerce template files into your current theme and integrate your html, here you can find the woo theme Integration guide http://docs.woothemes.com/documentation/plugins/woocommerce/woocommerce-codex/theming/


0

It turns out I just needed to return the $title variable which already had what I needed: function woocommerce_endpoint_titles( $title ) { $sep = ' | '; $sitetitle = get_bloginfo(); if ( is_wc_endpoint_url( 'view-order' ) ) { $title = 'View Order: ' . $sep . $sitetitle; } if ( is_wc_endpoint_url( 'edit-account' ) ) { ...


1

You need to explode the comma separated string to get the array of IDs. Follow the below code. $cookie_array = $_COOKIE["your-results"]; // Test output echo $cookie_array; $cookie_array = array_map( 'absint', (array) explode(',', $cookie_array) ); $sug_args = array( 'post_type' => 'product', 'post__in' => $cookie_array, ); ...


0

I was able to do this a while back by following this WooCommerce tutorial: There may come a time where you would like change the text displayed on a product's page when it is In Stock or Out of Stock. Simply add the following code to the 'custom functions' area of your functions.php file: /** * Change In Stock / Out of Stock Text */ ...


0

content-single-product.php sounds like a woocommerce template, which is located here wp-content/plugins/woocommerce/templates. You can override this template in your theme or child them by creating a file wp-content/themes/your-theme/woocommerce/content-single-product.php.


0

Using the [woocommerce_my_account] shortcode, a user will see their account details if they're logged in and if they're not logged in, they'll see a login and registration form. Using the same page title "My Account" for these different users isn't ideal because a user that has never created an account won't naturally navigate to a "My Account" page in ...


0

This is not a casual task, nor do I think will you be able to find a free plugin to do that for you. How are your PHP skills? If not so much (and based on the casual way you've asked the question) I'm assuming they are zero, you will need to write up a specification for what you want, then pay a developer to create the product for you.


0

Looking at the function update_woocommerce_term_meta(), you would recognize it just uses the wordpress function update_metadata(), which essentially means that woocommerce is using meta values, just like you do in you CPT. With this in mind, I wouldn't think this procedure would slow down your site + your keeping compatibility by using existing functions. ...


0

If you're using WooCommerce, they have a shortcode that displays the logged in user's account details on a front end page: [woocommerce_my_account]


0

Okay, for anyone looking to include the WooCommerce review tab not on an actual single-product page here's the secret sauce: In your template file, you need: global $withcomments; $withcomments = true; Then add a filter for the comments template: //add filter to use our custom review template add_filter('comments_template','{{YOUR_HELPER_FUNCTION}}'); ...



Top 50 recent answers are included