WordPress WooCommerce - Custom Add-To-Cart URL with Add ons parameter - php

I want to use the add-to-cart URL to add Products into the cart.
The normal URL is like that: siteurl.com/?add-to-cart=123
Now I use the "Woocommerce Product Add-On" for Custom Parameter like "Size" as an example.
How I can add these parameters to the custom add to cart url?

Here things were originally complicated, but now it’s much easier! All you need is the variation ID. Here’s where you can find it:
href=”http://example.com/?add-to-cart=88"
Or you can use like this.
http://example.com/cart/?add-to-cart=PRODUCT_ID&variation_id=VARIATION_ID&attribute_pa_colour=black
http://example.com/cart/?add-to-cart=PRODUCT_ID&variation_id=VARIATION_ID&attribute_pa_size=32

Related

WP Woocommerce linked product search in admin - too much score

I would like to modify the behavior of upsells and cross-sells product search in the admin product edit. It should search only in product titles.
By default, it searches description as well. That’s why there are too many score, I can’t find the product what I search.
[1
I had the same problem with the frontend product finder, but I solved it with a hook. Is there any hook for upsell and cross-sell finder?
Thanks!
The search request goes to this function
https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php#L1582
There you can find a filter woocommerce_product_pre_search_products for a custom result, so basically you'll have to copy-paste the whole code below that filter line and remove a few things from line no 1651 or you can just modify the core plugin files.
However, I don't see any specific param to identify the request so this change will affect everywhere on the website where search_products is used from the data store.

How to disable the ability to change shipping method on the checkout page in WooCommerce

I would like to disable the ability to change shipping method on the Checkout page in WooCommerce. The user selects the shipping method on the Cart page and I do not want to let them change it on the Checkout page.
I'm looking for some filter that can be used there. What I found is woocommerce_cart_ready_to_calc_shipping but it completely hides it.
Note: I would not like to overwrite the template file so I am looking for an way with a filter or action

Add a custom field in woocommerce attributes

Does anybody knows what hooks I need to look at if I want to add additional field into woocommerce new attributes page?
I have slug, but I'd like to add icon field where you'll be able to add icon name, and that will be outputted next to the attribute? And that input field should be below the slug input.
I found the woocommerce_attribute_taxonomies function, but I'm not sure how to edit it properly without changing the plugin directly.
After looking at woo's webhooks I couldn't find anything that would help. But I did notice that when editing the attribute I wished to add a field to there was this in the url: /wp-admin/edit-tags.php?taxonomy=pa_brand&post_type=product. Every time an attribute is created Woo creates this as a custom tax. This means you can use this tax to create custom metaboxes.
Either by using this tutorial https://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/ or a dev toolkit such as CMB2 : https://github.com/WebDevStudios/CMB2
Hope this helps someone!

Woocommerce Custom Add to Cart URL

I have a question with adding a product to the cart via a url. Right now I can use http://example.com/cart/?add-to-cart=49 and it will add the item to the cart. I'm using a plugin that adds a custom text input to each product. The plugin is WooCommerce Extra Product Options on codecanyon.
I need to add a parameter to my add to cart url where I can add an item to the cart but also pass a value to that custom input through the url as well. Ideally my url would look something like http://example.com/cart/?add-to-cart=49&textbox=myvalue. I'm really not sure the best way to approach this. I'm not against not using that plugin either if there is a better way to make this work. Thanks for your help.

WooCommerce - building a custom api

For specific product needs, I am creating a custom api for my application to query WooCommerce.
I am able to hook into the 'parse_request' action, but it would seem that this is too early for woocommerce to be correctly setup.
I know this because if I try to query for order information, I am getting back error objects saying that taxonomie is incorrect.
What do I need to do to correctly have woocommerce initialised so that I can query for orders and products (along with their custom attributes) ?
Can anyone help me with this ?
I'm not sure I fully understand what you are trying to do so I will attempt to cover both possibilities.
The WooCommerce API can be accessed via https://www.example.com/wc-api/v1/.
Alternatively, WooCommerce is fully loaded by the time plugins_loaded is fired (aka when all plugins are done loading). To do something specifically when WooCommerce is loaded you can use woocommerce_loaded. But parse_request comes after plugins_loaded and even comes after init which is where WooCommerce is loading its taxonomies. Are you sure you are using the correct taxonomy names? For example, Attribute taxonomies are preceded by pa_ so a Color attribute would have a taxonomy of pa_color.
If you adjust your question to clarify what you are doing I might be able to help further.

Categories