Get related Products in the WooCommerce widget Sidebar - php

Does anyone have any idea how you can put related products in the sidebar in WooCommerce?
Something like in this screenshot:

1) You can use this code to enable Shortcode execution in the text widget
// Enable shortcode execution in text widget
add_filter ('widget_text', 'do_shortcode');
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
2) Then in Wordpress widget, you will able to add and use the text widget adding to it:
[related_products per_page="4" columns="1"]
But you will have to make some custom CSS for it, to get the display that you want… Or to build your own custom widget (or shortcode).

Related

Wordpress - How to change the category page to full list views?

I want to change the category page to show all its post in a single category page, without any pagination, meta tags, snippets and images. Like the "Recent Posts" widget.
Is that possible? I tried a code in the theme functions but no luck. Can anyone help me out.
Create a child theme of the main theme. And then create a category.php file in the child theme so that it override the parent theme category.php. Then you can use the WordPress loop to list the cateogry post as you desire.

Adjust the text below returning customer

I want to change the text at the checkout page below the returning customer bar, namely "If you have shopped with us before, please enter your details below. If you are a new customer, please proceed to the Billing & Shipping section.".
The text seems to be present in: plugins\woocommerce\i18n\languages\woocommerce.pot
and plugins\woocommerce\templates\checkout\form-login.php
I know I can simply adjust the text in those files; but if WooCommerce gets updated it will be overwritten.
Is there a way to change this text with hooks, although the text doesn't appear in my theme?
I don't want to use a plugin for this if possible.
When Overriding Woocommerce templates via a child theme (or a theme) you will not loose any changes when Woocommerce plugin is updated.
So in your case, as explained on the comment of the template checkout\form-login.php you will have to copy this file to your child theme:
/**
* Checkout login form
*
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-login.php.
Woocommerce templates are made to be overridden via a child theme (or theme)
See: WooCommerce action hooks and overriding templates
While working on a custom theme, you can achieve this functionality by copying same template to your-theme/woocommerce/checkout/form-login.php.
Now you can update plugin without losing the changes.

custom widget including both theme n plugin?

Looking forward adding page attributes to woocommerce product page as my website WordPress picks up default sidebar or custom sidebar of responsive theme. so how can I have custom widget on product page which includes woocommerce widgets n not default page widgets of theme.
Install WooSidebars plugin by Woothemes
In Admin panel, go to Appearance/Widget Areas, then create your custom widgets.
Kindly check image which explains well

Use default WooCommerce Gallery

My WooCommerce theme has a custom gallery that is coded directly into single-product.php. Rather than using this custom gallery, I wish to display images on the product screen with the original default Woo Commerce gallery.
The files in the plugin that I believe display the default gallery are:
product-image.php
product-thumbnails.php
I'm new to server side programming and PHP. I've tried the following code:
<?php wc_get_template_part( 'content', 'product-images' ); ?>
<?php wc_get_template_part( 'content', 'product-thumbnails' ); ?>
But this doesn't return anything.
How do revert to the original WooCommerce gallery when my theme has an image gallery hard coded into single.php?
In your case it seems that your theme has custom woocommerce templates files inside it. The trick could be trying replace some of those templates files, by the original ones. The better way to do that is to set a child theme, avoiding theme updates problems…
1) If you are using a child theme:
Copy the woocommerce folder located in your parent theme to your child theme.
Replace from the woocommerce plugin, templates folder, the needed templates files to the woocommerce folder inside your active child theme.
2) If you are not using a child theme, Just replace from the woocommerce plugin, templates folder, the needed templates files to the woocommerce folder inside your active theme.
Reference: Overriding Templates via a Theme

Wordpress about a tutorial

I want to know something about this article
In order to create custom post types, open your template’s
functions.php file in an editor, and
place the following function within
the file:
Where is this file function.php in wordpress 3.0.3
You must open the file functions.php that is in your template directory, in /wp-content/themes/your-theme-name.
If the file is not present, create it.
It is /wp-content/themes/[name-of-theme]/functions.php
e.g if twentyten (default theme)
/wp-content/themes/twentyten/functions.php
Custom post types and custom taxonomies should be added through a plugin, and not through a theme. It is the recommended way to add these.
Just a couple of reasons why you should add custom post types and taxonomies via a plugin
custom post types and custom taxonomies add functionality to your site, and not your theme. They also do not add visual benefit to your theme
custom post types and custom taxonomies should remain available across themes. If a theme is changed, these should still be available to the next theme activated

Categories