Package templates #16
Reference in New Issue
Block a user
Delete Branch "templates"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Smoke Test
Note: There is now a new product type called Template to handle package templates. You can select it among other product types, and a new Taxonomy called Template Category (to replace virtual product). The Taxonomy UI is added in admin panel
First you need a setup:
At least...
2 Template Categories: Example (Camera holders, Cameras)
2 Simple products: - These Are Real world products and they also MUST have one Template category selected
1 Template -
You can add your Template categories to any of the tabs.
1 Bundled Product
Select bundled product from product selection dropdown
Notice the template selection meta box will show
Select your template
Categories from templates and their quantities must show
Save bundled product (The error message should show since you did not add any product to bundle)
Get back to bundled product tab
Add real world simple products to the bundle
Modify the max_quantity for this product to be the SAME as quantity for Template categories
Save your bundle product. If you have done everything correctly no error or info message should show
Change max_quantity of any of your bundled product to be different than quantity of Template category that that real world products shares category with.
An different error message will show , telling you witch categories don't have correct quantities.
changed title from [WIP]{-Added templates product-} to [WIP]{+Package templates+}
added 1 commit
Compare with previous version
added 1 commit
Compare with previous version
added 1 commit
Compare with previous version
added 1 commit
Compare with previous version
added 1 commit
Compare with previous version
added 1 commit
Compare with previous version
added 1 commit
Compare with previous version
changed the description
added 1 commit
Compare with previous version
unmarked as a Work In Progress
assigned to @akrdzic
changed the description
Please merge changes from master branch into this one.
added 20 commits
masterf2d3efc5- Added templates productCompare with previous version
added 1 commit
43408382- Repalced virtual product with template categoryCompare with previous version
changed the description
When I add Camera Holder and Camera Unit categories one after the another, the second one gets displayed as CameraHolderCameraUnit
Also it would be very helpful for the user if template description would be in format
Category x[Number]
added 1 commit
94ba6976- Show downlodable files only for simple and bundlesCompare with previous version
added 1 commit
246656bc- Fixed template category double title bugCompare with previous version
Remove
error_logThis should be inside
includes/templateand not here. Here is only logic that is specific for admin interface.This is fixed
This is fixed
changed this line in version 14 of the diff
changed this line in version 14 of the diff
added 1 commit
d3b0d101- Deleted error logsCompare with previous version
I will merge this PR since demo is today and will add more comments to this PR after i review and merge profiles and will add another card for it.
merged
mentioned in commit
cf92f62703resolved all discussions
We should check with Senad if template categories should have hardware, software, installation and service as root parents, since currently that is not implemented and it mabe should be (actually probably should be).
A lot of code that is specific for woocoommerce product search could be avoided here if woocoommerce product search was not used.
Instead I think that simple input field with JQuery autocomplete feature could be used.
This way:
The same code is repeated 4 times.
Also
<a>element can have id of the category as data property so it could be used to build id of corresponding element that should be removed or something similar.Maybe rename this to
add_template_product_meta_boxAlso this to
add_template_product_metabox_contentLet us try not mix view code with logic, since we already have views for this.
Let us try to keep logic here and presentation in views and only if html code is really small so it does not justify adding view we can have it directly in a function.
This way of getting information from template should not be here. It should be inside of
class-wiaas-wc-product-template.phpand accessed with correspoding methods.The same as above, this whole logic of accessing metadata to retrieve categories, quantities and corresponding metadata should be in
class-wiaas-wc-product-template.php.From there
Wiaas_Template_Category_Objectobjects are to be requested.This validation logic should also be moved somewhere else. Maybe to new
wiaas-template-functions.phpfile where these functions that are not binding to single template object but implement template logic can be.It is important to know that this admin part is only for admin interface, and whole application logic should work even if this admin folder is deleted and wp admin interface is replaced with some other interface.
The same as above, this logic should be move somewhere else and only called here as method or function.
Admin folder cannot contain our core logic implementation.
The same as above. This logic should not be in
adminbut somewhere else.This function does not search correctly since
termshould be retrieved from$_GETand not$_POST. Currently it probably searches with emptyname__likeoption.Use:
Again since presentation code is pretty large we should keep it in views template for better overview of the implemented logic.
I am not really sure why do we need this as separate class. It has no separate logic to justify separating it into its own class. It is only array of properties: (
category_id,name,quantity).I am not sure when and where is this used. Maybe for previous implementation? If so, then it is obsolete.
Again, since this presentation code is large enough that it should be separated to its own view template.
As I presented in my first comment regarding js code for handling product search, this select is not necessary for features needed here. I think it could be replaced with simple text input field that will be used with jQuery autocomplete feature.
Also, side note
data-action="woocommerce_json_search_products"is obsolete and not used. This part should bedata-action="my_custom_search_endpoint"when used with custom search endpoint. Leaving it as it is and then implementing ajax search in .js defies its purpose.adminfolder should not be aware that these properties are saved as template product metadata. It should be handled insideclass-wiaas-wc-product-template.phpand here only called as a method.Also, since there are many instances of this to avoid marking every one of them I will just say it here:
Places where category ids are saved and displayed should not be referred to as products. That remained from previous implementation and should be correctly changed to template category to reflect new implementation.
I made new card for handling this code review: https://app.asana.com/0/697944902557002/832515489359311
There was a lot of code in this file, that was not supposed to be here in the first place and now there is no more code that is specific for woocoommerce product search.
I see how your example with jquery and inplut could work. But I still think that using this woocomerce ui is not a big deal.
You shnould check the new version of this file in new PR , and tell me what you think
fixed
Fixed
I am not really sure about what you ment here
Fixed
Fixed
The line of code (140) that you added a comment for does not have anything to do with validation.
If you were referring to validate_bundle() method.
Than I think that this method is exactly where it is supposed to be, since it activates on woocommerce_admin_process_product_object hook, and uses Admin notifications UI. So I don't see it being part of any other part of the project, except for admin panel.
EDIT: I see you addressed the issue ova validate_bundle() method in another comment, and I see now that you refered to
get_bundled_product_categoriesmethod as validation logic. As far as this issue goes. it is fixedI agree with you here, but I do need to have a method here that can be activated when woocommerce_process_product_meta_bundle hook fires. I moved the actual saving to DB part to another method and file that is not in admin panel
I think that this method is exactly where it is supposed to be, since it activates on woocommerce_admin_process_product_object hook, and uses Admin notifications UI, So I don't see it as
corelogic and being part of any other part of the project, except for admin panel.Wow .. my bad... Fixed
I don't get this reference. What do you mean by views template ??? And "presentation code" being pretty large
This class was created , at first for compering object to object( both ID and quantity and name) by 'equals' method. I did not go trough with that logic.
And I don't see it's purpose now , i don't find it harmful to stay this way.
It is a dead code..
Fixed
And again, I don't get this reference
I have removed
woocommerce_json_search_productssince it is not used.As for, the whole select, I have explained before, that I don't see the problem, and I find it simpler this way instead of using jquery atocompleate.
Woocomerce bundled products is using this same UI, and for consistency I find it more acceptable to have the same search box, instead of different UI for every product type that we have.
This part was taken from woocomerce project structure.
The processing of the actual data (extracting it from post) should be the part of admin PANEL since it is related to admin UI
You can check woocomerce code for metaboxes for that.
Only thing that should not be here is an actual method that saves data to DB
update_post_meta($post_id, '_template_items_' . $option, $processed_template_data);I have moved this method