woocommerce show attributes on shop page

Have you ever seen that the product list page displays product attributes such as color, and size? You see that it is so attractive but you do not know how to this. This article woocommerce show attributes on shop page will help you. Attributes are quite important as they are the criteria used to filter products. For instance, you filter products by color, or size, etc.

woocommerce show attributes on shop page
This article will guide you on doing the following things

Display attributes for each product on the shop page

Because we display attributes after displaying title, we use the following function woocommerce_shop_loop_item_title. You should see the code below to edit appropriately. Firstly, we just apply it to variant products. If they are not variant products, we do nothing. If products do not have any attribute, we also do not process.


functioniconic_available_attributes() {
global $product;
if ( ! $product->is_type( 'variable' ) ) {
return;
}
$attributes = iconic_get_available_attributes( $product );
if ( empty( $attributes ) ) {
return;
}
foreach ( $attributes as $attribute ) {
?>
<div class="iconic-available-attributes">
<p class="iconic-available-attributes__title"><?php _e( 'Available', 'iconic' ); ?><strong><?php echo $attribute['name']; ?></strong></p>
<ul class="iconic-available-attributes__values">
<?phpforeach ( $attribute['values'] as $value ) { ?>
<li class="iconic-available-attributes__value<?php echo $value['available'] ? '' : 'iconic-available-attributes__value--unavailable'; ?>"><?php echo $value['name']; ?></li>
<?php } ?>
</ul>
</div>
<?php
}
}
 
add_action( 'woocommerce_shop_loop_item_title', 'iconic_available_attributes', 20 );
  
Next, you continue to use the code below
functioniconic_get_available_attributes( $product ) {
static $available_attributes = array();
$product_id = $product->get_id();
if ( isset( $available_attributes[ $product_id ] ) ) {
return $available_attributes[ $product_id ];
}
$available_attributes[ $product_id ] = array();
$attributes = $product->get_variation_attributes();
if ( empty( $attributes ) ) {
return $available_attributes[ $product_id ];
}
$attributes_to_show = iconic_get_attributes_to_show();
foreach ( $attributes as $attribute => $values ) {
if ( ! in_array( $attribute, $attributes_to_show ) ) {
continue;
}
$available_attribute = iconic_get_available_attribute( $product, $attribute, $values );
if ( empty( $available_attribute ) ) {
continue;
}
$available_attributes[ $product_id ][] = $available_attribute;
}
return $available_attributes[ $product_id ];
}

Next, you use the following code. This function includes three parameters which are $product, $attrbute ,$value. They will return the following values
Slug: it is the slug of attribute,
Name : is the name of attribute
Values is the list of attributes including name and available

 
functioniconic_get_available_attribute( $product, $attribute, $values ) {
$available_attribute = array(
'slug' => $attribute,
);
if ( ! taxonomy_exists( $attribute ) ) {
$available_attribute['name'] = $attribute;
foreach ( $values as $value ) {
$available_attribute['values'][ $value ] = array(
'name'      => $value,
'available' =>iconic_has_available_variation( $product, $attribute, $value ),
);
}
return $available_attribute;
}
$taxonomy = get_taxonomy( $attribute );
$labels   = get_taxonomy_labels( $taxonomy );
$available_attribute['name']   = $labels->singular_name;
$available_attribute['values'] = array();
foreach ( $values as $value ) {
$term = get_term_by( 'slug', $value, $attribute );
if ( ! $term ) {
continue;
}
$available_attribute['values'][ $value ] = array(
'name'      => $term->name,
'available' =>iconic_has_available_variation( $product, $attribute, $value ),
);
}
return $available_attribute;
}
Finally, we use the following function to complete.

functioniconic_has_available_variation( $product, $attribute, $value ) {
$available_variation = false;
$attribute           = 'attribute_' .sanitize_title( $attribute );
$variations          = $product->get_available_variations();
 
if ( empty( $variations ) ) {
return $available_variation;
}
 
foreach ( $variations as $variation ) {
foreach ( $variation['attributes'] as $variation_attribute_name => $variation_attribute_value ) {
if ( $attribute !== $variation_attribute_name ) {
continue;
}
 
if ( $value !== $variation_attribute_value&& ! empty( $variation_attribute_value ) ) {
continue;
}
 
$available_variation = $variation['is_purchasable'] && $variation['is_in_stock'];
break;
}
 
if ( $available_variation ) {
break;
}
}
 
return $available_variation;
}
 

After adding function.php file to the theme folder, we will check the front end to see the result. After styling a little bit, we have the result as that at the beginning of this article.

There are some people adding these codes but still face woocommerce show attributes on shop page. They are products to which attributes are not added. Or this category just includes simple products.

Attributes of product have lots of applications in practice. Along with product type, they are used to perform products’ features which are more clearly than using description. Besides, based on the features, filtering products can be done. You could read this article for more information.

If you have any problem with woocommerce show attributes on shop page, please leave a feedback or contact us. We will support you to solve your problem.

shopify product types

shopify product types and collect is used to distinguish products. If your store contain lots od products, product type is used as a criterion in filtering products. Filtering products help customers to know if their favorite products are in stock or not.

Input product type

When creating product information, shopify product types can be inputted manually or getting information entered before by clicking on dropdown button as below

shopify product types

Display list off the unique shopifyproduct types

To display the list of product types, you could use the following code:

{% for product_type in shop.types %}
{{ product_type | link_to_type }}
{% endfor %}

You can refer to this link https://help.shopify.com/en/themes/liquid/objects/shop for more information.

Filter products by product type

Being different from other source codes, Shopify does not allow user as well as developers to intervene in the source code. Therefore, we cannot directly filter products by product type but use the product tag. The core of this method is filtering products by tag. And for each product, we have to add one tag which is the same as the product type.

Get to Product of Shopify, add one product tag which is the same as the product type. You should take a look at the figure below to understand more. This product has the product type “Coat” so we add the tag “Coat”. Similarly, we add tags for the rest products.

shopify product types

Get to collection-template.liquid file to add the code below

<!--add-->
<div style="float:left">
<h2>Filter by product type</h2>
<ul class="filter-list filter-text">
{% for product_type in collection.all_types %}
{% assign product_type_tag = product_type | handle %}
{% if product_type_tag != '' %}
{% if collection.all_tags contains product_type or collection.tags contains product_type %}
<li>
<a href="{{ product_type | handle }}">{{product_type}}</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
</div>
<!----end add-->

In the debut theme, we have tested and add at line 143 at the moment. In the real project, you should customize or find the most suitable place to add.

shopify product types

Here is the result in front end.

shopify product types

You have read the article shopify product types and its application in filtering products. However, this article just guides you on filtering product by type. In the next article, we will introduce more product filter criteria. If you do not want to edit code, you could use Product filter app. This app has many criteria to filter. You do need to input them manually. This app will save your time and effort with drag and drop feature.

If you have any question, please let us know. We will help you solve your problem.

Prestashop Order Edit module

Prestashop Order Edit module is the tool launched to replace the Prestashop default feature which still has short comings. You save your times with bulk operations by one click. Duplicating, editing, adding and deleting order are extremely easy and simple.

Prestashop Order Edit module

Process orders in bulk

Have you ever wasted a lot of time to process a huge number of orders at the same time. If you have 100 orders, you have to open them 100 times, and print them. These operations repeat monotonically like that? Or you want to change the status of 90 or 100 orders, you have to open them, change their status and save them one by one if you use the default feature. How do you think if all the repeated tasks are done by one click? It is the reason why you should continue reading or finding more information about Prestashop Order Edit module.

Edit orders easily

After placing an order, your customers could send an email or take a call to ask you to edit the products, payments, and delivery, etc. This time you will feel that how beneficial Prestashop Order Edit module really is. Here is the list of things that the module supports to edit:

  • Product: You can add, delete fields such as name, quantity, price, and custom properties
  • Delivery: Edit suppliers who provide shipping services. You also can edit the delivery information, tax, cost and weight
  • Payment: You can edit the time of payment, the amount of payment, and the method of payment, etc.
  • Add, and edit voucher code
  • Edit reference code
  • Edit the payment address, delivery address without reloading the web page.

Duplicate an order

By this way, you can quickly create an order depending on an existing order. This feature may be helpful in case that it is an old customer calling you to order. You just need to open the old order of this customer and select the new products he has just ordered. In general, you can edit everything:

  • Edit products: Add, edit, delete existing products
  • Edit customers: Add new or use registered customers’ account
  • Edit delivery: Edit the methods of delivery
  • Edit payment: Edit the payment method
  • Edit order status: edit the order status of new customers

We have just run through order edit. If you are interested in this module, please get access to https://addons.prestashop.com/en/order-management/23748-order-edit.html to have a trial as well as test the module demo before purchasing. However, I think you should own this module if you are the people who respect time because its efficiency is much larger than its cost.

 

 

How to Properly Delete All WooCommerce Products

Have you ever thought that you will remove all the current products and import product the new ones?  To Delete All WooCommerce Products is extremely necessary at this moment. So far, woocommerce has not had a proper feature to do this task. If you have just 10 products, you can do it manually. But if you have 10.000 products, you have another thought. There are some fee-charging plugins but I have never used them. I have used some free plugins but they do not support you to delete taxonomy.

To me, deleting products by with database is quickest and simplest. If you follow this article, you may do it better than me because you just need to copy and click the “run” command.

Log inphpmyadmin

There are several ways to log in. You can get access to the link youdomain/phpminiadmin or use phpminiadmin.php. Or you can carry out in the cpanel of hosting. If you are not sure about this, you should contact your hosting supplier. If there is more than one database and you are not sure which database you are working with, you should open the database and get to wp_options. This table lets you know which url of the website the database is working on.

Or you can open wp-config.php file to check the corresponding database.

Run the SQL command

After defining the exact database, the first thing to do is back up the database because you may destroy your website accidentally. Next, you click on SQL as below

Delete All WooCommerce Products

DELETE relations.*, taxes.*, terms.*

FROM wp_term_relationships AS relations

INNER JOIN wp_term_taxonomy AS taxes

ON relations.term_taxonomy_id=taxes.term_taxonomy_id

INNER JOIN wp_terms AS terms

ON taxes.term_id=terms.term_id

WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type=’product’);

DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = ‘product’);

DELETE FROM wp_posts WHERE post_type = ‘product’;

Delete All WooCommerce Products

Now, click on Go. All the products will be deleted. If it shows error, commonly it is due to your wrong prefix. The code uses default WordPresswp_. However, if you use automatic installation service of the hosting supplier, the code may be changed. You should check if the name of the table is right. On the left of the screen, it has the format of prefix_post, as wp_post by default. You should edit it properly.

The article Delete All WooCommerce Products ends here. If you have any question, please contact us. As we have mentioned, this solution is used when you want to import all new products. If you use Prestashop, you could try using Import product module here https://addons.prestashop.com/en/fast-mass-updates/27281-csv-import-products.html You can use the demo site before deciding to own this module. You are also provided with technical support by the support team when using it.

 

 

 

What is the difference between import and export

“ What is the difference between import and export ” is the question that many people are interested in. There are different answers in different fields which cause disputes between people. However, we can see the difference clearly when deeply studying this issue. Therefore, this article focuses on explaining to the readers so that you can understand well.

What is the difference between import and export

Firstly, we can understand that import is related to input while export is related to output. Experts in information technology have different perspectives with people work in financial and economic field.

From the perspective of information technology

Import is the process of information input. When we talk about software, the input information could be texts, media files such as music and film. Or you must have heard the phrase “import product”. This is the process you importing products information to database. Thousands of products can be imported in several minutes.

Export is the process of information output. In computer software, the export information could also be texts, and video files, etc. Similarly, exporting product is the process of outputting product information to excel, csv, xml, etc. It is to get these files to send to others who will use them to import information to their computer as the process above.

From the perspective of the economy

What is the difference between import and export ? It is not limited in the scope of a computer. Its meaning covers the scope of international.

Import is the process of local companies purchasing goods or services from other countries. The reasons import is that these kinds of products meet the demand of domestic users at reasonable prices. Or local enterprises do not have enough capacity to produce them due to out of date facilities or high manufacturing costs. Import turnover depends primarily on the exchange rate. If the domestic currency is stronger, you will buy more foreign currency. It means you will increase the import turnover.

Export is when local companies sell goods and services to others countries. It happens when the domestic manufacturing costs are lower. Or companies want to penetrate new markets and internationalize their products. Or maybe local consumers do not have demand for these kinds of products. The positive effect of export is that it reduces the issue of supply much more than demand within the country. As well as import, export is related to the exchange rate. If the domestic currency is weak, the exporter will get more when exchange foreign currency to domestic currency. Therefore they want to export more.

We have finished the article “ what is the difference between import and export ”. There may be many meanings in other fields but we stop here. Let us know if you have any comment. We are looking forward to hearing from you.