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.
Related
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.
I found a issue with woocommerce and variable products.
The products works good on the frontend but If I try to do the same from the backend, I can't selected the variations that I want.
I just can add a meta (It's an input text field) and this is very limited.
Can I fix this with a hook/function or plugin?
Really need help.
Thanks,
Your question is somewhat difficult to understand. Are you asking if you can change the combination of variations for a product on the backend after an order has been made?
I have only ever been able to do such a thing, in certain situations from within fulfillment software (ShipStation in my case), and even then it's no simple task. The reason likely being due to the fact that WooCommerce essentially locks the order after payment, as a failsafe to the customer probably.
I'm currently attempting to extend the inherent Magento product view to divide the custom options belonging to a configurable product into sections loaded by ajax. The end goal is to create a step by step process guiding the user through each step of the product configuration process before they would add the product to the cart.
Advanced Custom Product Options
We are also utilizing Mageworx's Advanced Custom Product Options to allow for the larger customization of products.
Simple Products Linked to Configurable
Our current environment is set up to handle simple products as configurators for their parent configurable product. When a user navigates to the simple product, they are directed to the configurable product with the option represented by the simple product pre-selected.
End Goal
The hopeful endpoint would be that once a user clicks on a simple product, they would be redirected to the configurable product with a single pre-selected option depending on the simple product. The user would then be able to customize their order, or jump directly to adding it to the cart as is. The customization process would re-evaluate at each step to determine if there is a concurrent step, for example, if the user were to select to add trim, there would be an additional step to customize that trim, whereas if they opted out, the step would be skipped.
The idea is simply a product configurator within the Magento framework, something similar, in function, as to what appears below. The checkout steps being Style, Color, and Size, each which have their own page.
The Overarching Question
I am fairly new to the development of Magento, and am wondering what the best method of attacking this problem is. I have thought of using an observer to hook into before add to cart, but I am unsure it would allow me to refresh the blocks and load in new data. My other idea was to tap into view.phtml and set up some ajax loading within the page itself, but that seemed a bit 'hacky'.
I have spent quite a while searching for examples on how some have overcome this problems, but haven't found much outside of some very vague ideas on what could work. If any one has insight onto a solution to my problem, their thoughts would be much appreciated.
Current Approach
So far I've tried creating a Router for a Controller to handle POST requests to change out the Product Option sidebar when a value is changed. It seems a little bit slow, however.
Hope someone can point me in the right direction, we have a custom plugin for wooommerce, developer left us!!!
The custom plugin is a custom post type, actually a bundle with many custom weights making up the product, to keep it simple think of it has a cake with ingredients.
The owner now wants the product (custom product type) to have 3 variations.
This will never change always 3 no more no less.
I can find tuitions on creating custom product types, but nothing is out there calling variations into a custom product type.
I need to get the basic workings correct so as i approach other developers i can gauge what is going on.
I know i am being vague but i cannot post the plugin on here.
I keep seeing reference to the Class: WC_Product_Variable
Do i need the plugin to add a function for variables to be switched on as such, with a call to a variable function file.
Also calling an add to cart variable file.
Can some of the code be used from the woocommerce file class-wc-product-variation.php
help and guidance aprreciated
I am working on a website where I am using woocommerce but rather than have a shopping facility I'm trying to change the wording, whilst keeping all the functionality to be able to add products to the shopping cart but calling everything an enquiry, and call for quote in replace for prices.
I have set prices so that when 0 is entered it won't display the standard 'Free!' and instead it states 'Call for quote' by adding this to my functions.php
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' ); // 2.1 +
function woo_custom_cart_button_text() {
return __( 'Add to Enquiry', 'woocommerce' );
}
This works fine, and i sourced this particular hook online to obtain the code, however now I am starting to get further into the project I am wanting to edit more than just button texts.
My question is, how do you know where to obtain the hook names so I can start to create my own hooks for this, can they be seen from the class names when inspecting on google devtools? Dragging the woocommerce folder over into Sublime Text 2 and conducting a search for woocommerce_product_single_add_to_cart_text I can be returned with reults to be able to see that hook, but how do you come across the hook name to begin with?
I have looked at http://docs.woothemes.com/wc-apidocs/hook-docs.html but couldn't see any names in relation to the above hook to begin trying to decipher how or where it was obtained.
how do you know where to obtain the hook names so I can start to
create my own hooks for this, can they be seen from the class names
when inspecting on google devtools?
No.
To find a particular hook, you'd need to look at the code base. In repositories that are well organised such as WooCommerce, you should generally have a rough idea where to look for a particular hook.
For example, if I wanted hook in to the thankyou page I would probably first try looking in templates > checkout > thankyou.php. There I would find the woocommerce_thankyou action hook which would let me insert my custom functionality.
Alternatively, there's the WooCommerce hook documentation.