Custom loop for getting products flagged as new - woocommerce

I was looking for a way to build a custom loop to get the products flagged with the "new" label.
I could use the sort from the insert time, but that would always include a certain number of products, my goal here is to get those products that conform to the WooCommerce setting that says the product is considered new for a given number of days.

i have a free plugin - WooCommerce Product Badge, it has your requested feature to display "New" label with certain days defined.

Related

WooCommerce - WooSquare Plus plugin - plus product variations must be an array

WooSquare plugin failed to synchronize products between WooCommerce and Square.
I had a look at the contents of the xxxx_woo_square_integration_logs table in the WordPress database. One of the log entries said - "variations must be an array". I had a brief look at the program that I thought was performing the synchronization, WooToSquareSynchronizer.php and it had a statement:
$product_variations = unserialize($productDetails['_product_attributes'][0]);
Despite variations having another meaning in WooCommerce, the code appears to suggest what we are talking about here is product attributes. I guessed that the code expects at least one attribute for each product. I added a single global attribute and then set that on each of my products. My products were then successfully synchronized. Note that this failure only occurred when creating products, not when updating products. Looking at the WooSquare plus documentation, product variations looked to managed with attributes but in my case, I was not using product variations.
P.S. Could someone with 1500 reputation please add "WooSquare plus" as a tag?
References:
https://apiexperts.io/documentation/woosquare-plus/ (NOT TO BE CONFUSED WITH WooSquare Pro!).
https://apiexperts.io/fast-support/
This is probably the free version - https://wordpress.org/support/plugin/woosquare/reviews/ - https://apiexperts.io/documentation/woosquare/

Algolia - WordPress custom ranking attribute by taxonomy / term

I have list of events that are correctly indexed into Algolia. I would like to be able to "order by" taxonomy/term.
1) first taxonomy is called events_weight (5 terms 1,2,3,4,5). I need the events to be able to order by the term displaying the ones that are 1 at the top and those that are 5 in the bottom. Is this at all possible?
2) second taxonomy is called events_status (active, inactive, promotion). Again I need to be able to order them. Promotion first, then active, then inactive. Is this possible?
Thank you
In your Algolia Dashboard, you can add the events_weight attributes as custom ranking.
For events_status, I would recommend you to convert the values to an integer, to use it as a custom ranking (or sorting).
You can add them both and decide which one go first. This video explains Algolia's tie breaking algorithm.

WooCommerce Custom Attribute being indexed but shows no results

We're running WordPress 4.7, WooCommerce 2.6.9 and the Algolia 1.6.0.
We've got 7 indexes setup:
Searchable posts [searchable_posts]
Posts [posts_post]
Pages [posts_page]
Products [posts_product]
Brands [terms_product_brand]
Product Categories [terms_product_cat]
Full Code [terms_pa_full-code]
The first 6 all return results as expected but Full Code [terms_pa_full-code], although indexed returns no results. However, there should be several 100 if not 1000 as if a product has a Full Code it is set to be 'Visible on the product page'.
Because it's showing as something that can be indexed I'm assuming we don't need to do any custom coding so not sure why it wouldn't display any results?
Has anyone experienced anything similar
The terms_pa_full-code does only contain some metadata, not the values which are them correctly pushed as part of the product data if everything goes well.
You can then use values of that taxonomy as a facet to display a list of available options given a user search query.
You can also register for the Algolia plugin for WooCommerce here: https://community.algolia.com/wordpress/#woocommerce and get this setup for you in a few clicks.

Drupal Commerce Products for printing company

I'm new to Commerce I hope some kind fellow could give me some directions here.
I am creating an ecommerce website for a printing company. I will give an example of what I require
For instance they will offer A6 flyers but these come in different specifications each with differing prices
Here is an example:
http://4frontdesigns.co.uk/Untitled-1.jpg
So down the left column are quantities of flyers and along thw top different speciifications of those flyers with the prices shown in the middle.
Any help much appreciated
Can I just add each variation of these one by one as it is not possible to just say that a certain additional attribute to the product will add so much $$ to the base price.
Would I just add each variation one by one then some how pull these all into one display?
You could use the commerce price table module like Flo suggested or look at the Price attributes Module https://www.drupal.org/project/commerce_pricing_attributes
It uses option sets and then add to (or subtract from) the price based on the selected attribute.
The answer for me was to create each product variation as its own product. So every variation gets added as a separate product.
If you are wondering how to add different variations to product such as paper size or colour, you would do this with taxonomy. Simply create a taxonomy term called colour and then add all the colours into this term that you would require.
Then when you create your product type in commerce, you would add this as an option to choose from when adding products by doing the following. Go to manange fields for the product type you want to add it for and add a new field, type of data = term reference. You will then select the desired taxonomy term and also there will be an option to 'Enable this field to function as an attribute field on Add to Cart forms.' - You want to select this!
Then what you do is create a product display and pull all these in to a single page, which then gives you drop down options to change, and the price changes accordingly in real time.
You can create a product display by creating a new content type first, call it product display... Then add a field to this content type which is a 'product reference'.
Now add new content, pick to create a product display (what we have just created) and choose the products that you want to appear on that page.
Then automatically Drupal Commerce will take care of the rest. Hope this helps someone!

Pagination in application which use firebase.com as database

Front end application will use firebase.com as database.
Application should work like blog:
Admin add / remove posts.
There are "home" page which show several articles per page with "Next" and "Prev" buttons and page which show single article.
Also I need deep linking.
I.e. when user enter URL http://mysite.com/page/2/ I need that application show last articles from 10 to 20, when user enter URL http://mysite.com/page/20/ application show last articles from 200 to 210. Usual pagination.
Main question - is it possible to achieve this if use firebase.com.
I read docs at firebase.com, I read posts here. "offset()" and "count()" will be in the future, use priority, in order to know count of items and not load all of them use additional counter.
Based on this I suppose this:
ADD POST action:
get value of posts counter
set priority for new post data equals to value of posts counter
increase value of posts counter
DELETE POST action
get value of priority for post data
query posts data which have value of priority more than priority for post data which will be deleted and decrease their value
decrease value for posts counter
GET POSTS FROM x TO y
postsRef.startAt(null, x).endAt(null, y).on(... and so on)
Thing which I not like in this way are actions for DELETE POST. Because index of posts will be from 0 to infinity and post with less priority is considered as post which was created earlier so if I have 100000000 posts and if I need to delete 1st post then I need to load data for 99999999 next posts and update their priority (index).
Is there any another way?
Thanks in advance, Konstantin
As you mentioned, offset() will be coming, which makes your job easier.
In the meantime, rather than using startAt and endAt in combination, you could use startAt and limit in combination to ensure you always get N results. That way, deleted items will be skipped. You then need to check the last id of each page before moving to the next to find the proper id to start on.

Resources