I am following this guide in order to use an add-to-cart URL to add a bundled product to my cart. My goal is to bundle 4 products into ONE and using the add-to-cart URL for this purpose:
Looking at the solution, it seems quite trivial to construct such a link and I am quite sure I did it correctly:
https://myshopurl.com/cart?add-to-cart=77229&quantity[6674]=1&quantity[7214]=1&quantity[5780]=1&quantity[5892]=1
In this case, 77229 is the ID of the bundled product while 6674, 7214, 5780 and 5892 are single products that I want to bundle into 77229
I get as far as adding the products into the cart all together but they are not bundled. It seems that the bundled product is ignored in this case.
I am not sure what I am doing wrong but something is not working as expected.
Is there any best practise on how to solve this problem? Do I need to add custom code to functions.php to make this work?
Thanks in advance.
You're using the solution for Grouped Products, which are not the same as Product Bundles. With Product Bundles, you add the products you want bundled using the Product Data meta box in the editor. At this point, you may be able to use a simple add-to-cart URL if you are bundling simple products. I haven't tested this. If you are bundling variable products, the add-to-cart URL becomes complicated. See https://www.alternativeradio.org/products/alem002-alem001/ for an example:
https://www.alternativeradio.org/products/alem002-alem001/?add-to-cart=11061&bundle_variation_id_61=5266&bundle_attribute_pa_format_61=mp3&bundle_variation_id_62=5262&bundle_attribute_pa_format_62=mp3
I don't even remember how I reverse engineered this.
Related
I need to totally customise WooCommerce checkout page. I can do a lot of things with Woocommerce programatically but this one is not an easy task since I need to divide these fields just like on the picture below.
Website is on this link: https://2houragency.com/. I can see that they have hidden some default Woocommerce HTML elements and created their own, but I am not sure how to do it by myself. And Wocommerce is not that easy to customise for this kind of pages.
Get into the templating documentation of WooCommerce here.
You'll probably want to use one of these template files to re-order/structure the checkout template.
You can find even more information in the Code Refference.
Is there any way to access a product with variations/options individual weight?
Currently have an old script pulling a basic product (no variations/options) through custom fields. Now I have products with variations all with different weights, so the custom fields solution no longer works...
Ideally I want to pull the product options weight to add to my script to total the cart's weight. Tried ?debug=context at the end of a localhost URL and could not find product option weight to be available on the cart page- are there other options to work around this??
I am on BigCommerce Cornerstone theme
From what I understand by reading your post, the best way to accomplish your goal will be with the storefront GraphQL API. Using GraphQL you can query each product in the cart and include the variant data with the weight. This will allow you to get the weight for all of the variants in the order and add them up to get the total.
I'd definitely suggest checking out the BigCommerce GraphQL Documentation for more information, as well as the Code Examples.
I made an e-commerce website before where I copied the template files inside WooCommerce and edited them to display the content how I wanted. But now I know of shortcode and WP_Query which can also be used to get the products / categories etc.
So what I am wondering is which method is best and are there times where you would use one method over another?
There is actually a time and place for different methods. Nix the shortcode though. Generally speaking you shouldn't "hard code" shortcodes into a custom theme (there are exceptions of course), unless you mean that you want to build in a shortcode that theme-users have access to.
That said, if you want to emulate WooCommerce's current style/layout with your own flair, or you want to extend the current templates, use the current template override method. Note this will lead to your theme getting "stale" at some point. WC does a decent job of not changing the templates too often, but it does happen and your theme should accommodate when that happens.
If you're doing something different with a list of products entirely that's not necessarily supposed to look ingrained in the WooCommerce structure, then you can use a custom WP_Query or Database query to accommodate your needs.
So effectively:
If you want to tweak, extend, or reduce the current WooCommerce structure, use template overrides
If you want a fully customized solution or need WC Products in a different capacity, use a custom query method.
Everything woocommerce do well.
No need to use WP_Query separately
If you wants customize the theme you can use add_action() and add_filter()
Also you can modify css.
Hooks Referance:
https://businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/
Problem 1:
I'm using WooCommerce on a WordPress and it adds product-category to the URLs.
domain.com/product-category/accessories/dishwashing
I need to remove 'product-category' from the URLs. Is there any way to modify the permalinks and remove them?
Problem 2:
Also, I want to change the permalink for the product.
Current url for product "Active AirClean (SF-AA 50) with TimeStrip" is: http://www.atimiele.co.uk/products/filters/active-airclean-sf-aa-50-with-timestrip/
I have a category structure for the product is:
accessories > floorcare > filters
So the url for the product shoud be
http://www.atimiele.co.uk/accessories/floorcare/filters/active-airclean-sf-aa-30-with-timestrip/
I believe that what you are trying to achieve is not possible with Woocommerce. My colleague tried to change this as well a couple of months ago without any success. If you do want to remove the slug from products+categories you can use a plugin. There are several plugins available, i don't know if I im allowed to post it here, but we used the Perfect seo url plugin for woocommerce. www.perfectseourl.com Although it costs a lot of money, it was a good choice.
Typically it will solve both of your questions. I would recommend not using too many 'subcategories' in your url structure. Try to use maximum 2 subcategories, for SEO reasons. Google will index only 3 levels.
Good luck!
I am using WP-3.5.1 and want to know how can we add more custom fields (image, radio, check-box, drop-down) while adding/editing category?
I found http://en.bainternet.info/2011/wordpress-category-extra-fields but first here author did not mention
Where to add his code?
For which version of wp this code be use?
What affect if we upgrade to latest version?
What must be pass extra_category_fields( $tag ) in?
so I start from wp-admin/edit-tags.php and paste his code right after where Slug field is defined but stuck on $tag what should be pass here?
Is there any plugin to add custom fields in category like More Field which is for posts?
First thing, there is a big red warning in that page:
So, clearly, you'd better use the new version.
Second, you should never modify core files (/wp-admin/edit-tags.php). The following Q&A explains where you should put code enhancements in your WordPress site:
Where to put my code: plugin or functions.php?
Restore your core files to its original state using the following instructions.
Try to always use the latest version of WordPress, Themes and Plugins, as having old code in your site may have serious security/performance implications.
The new version of Taxonomy Extra Fields has much more examples in its documentation, so probably your configuration doubts would change.
All that said, the plugin Advanced Custom Fields is able to put extra fields in Taxonomies (categories, tags, custom taxonomies) very easily, no coding required.
Okay:
To add image filed while add/edit category use this plugin it is awesome plugin.
http://wordpress.org/extend/plugins/categories-images/