WP-ecommerce Custom fields - wordpress

I have a wordpress e-commerce site with a plug-in installed Custom fields Version 1.4.5...
I added a new attribute called size and its a drop-down menu. it only shows up in the admin pages when I goto edit a product, but in wpsc-single_product.php it does not appear just one line of text. How do i get the drop-down to display on wpsc-single_product.php?

You can add fields manually to your theme by adding the following line:
<?php if( function_exists( 'wpsc_the_custom_fields' ) ) wpsc_the_custom_fields( 'slug=' ); ?>
Make sure to append your custom field slug to "slug="
e.g. 'slug=my-dropdown'

Related

How to show WooCommerce Categories on 'shop' page instead of products?

I have seen this question and answer. That does not work.
Setup
I am running:
WordPress 5.4.1
WooCommerce 4.1.1
I have a custom theme that overrides some of the WooCommerce templates by placing my own templates in: themes/my_theme/woocommerce/template-name.php
I have established that the shop page (homepage) uses the template archive-product.php. I have copied the this from plugins/woocommerce/templates/archive-product.php into my theme and made some minor HTML changes which work perfectly. There are no functional changes in my theme's copy, just some HTML.
The problem
I want the homepage to only show the store categories, as thumbnails. There is an option to set the shop page to show categories instead of products:
Appearance > Customize > WooCommerce > Catalogue
Shop page display has been set to Show Categories
However the shop homepage seems to ignore this setting entirely, and it still shows the products. It seems surprising that WooCommerce's own template does not honour this setting!
How do I find this setting in the template and then show the categories (as thumbnails) on the shop homepage?
Is there an equivalent to woocommerce_product_loop() for looping categories?
As a side note, the Storefront theme does honour the setting but Storefront does not have the template archive-product.php. Storefront seems to be highly abstracted and after much debugging of it / trying to take it apart I have so far not worked out which template file it is using for the shop page.
My theme is already in production and I just want to make an update so that the homepage shows the categories instead of going directly into the products list.
I found a workable solution. The WooCommerce default templates don't support the setting to show categories on the Shop page.
However using a shortcode with do_shortcode(), and a condition this can be achieved as follows:
if (is_shop()) {
echo do_shortcode('[product_categories hide_empty="0"]');
} else {
woocommerce_product_loop_start();
if ( wc_get_loop_prop( 'total' ) ) {
while ( have_posts() ) {
the_post();
/**
* Hook: woocommerce_shop_loop.
*/
do_action( 'woocommerce_shop_loop' );
wc_get_template_part( 'content', 'product' );
}
}
woocommerce_product_loop_end();
}
Still:
I would like to know how to pick up the 'show categories' customisation setting shown in the question, so my theme responds to that.
Is there a better way than using do_shortcode(), this feels like a bit of a hack

Can we replicate ACF functionality in our theme?

Hi i want to add advance custom fields in my wordpress theme. I don't need editor functionality but to provide the users the facility to enter the values to view in the frontend.
basically i want to add the custom fields in my theme just like ACF but i don't want to use the plugin. Is there anything anyone can help me out with this please do.
I'm using ACF plugin right now to add custom fields in my theme.
For example I'm getting the designation from user in the admin panel and our team members custom post type. and showing it on the home page by using this code.
<p><span class="fa fa-user-circle"></span> Designation</strong>:<?php echo the_field( 'designation' ); ?> </p>
I don't want to use ACF plugin to perform this task. I know about the wordpress custom field. The problem with wordpress custom field is I've to select the key every time when I create a post. Here's a sample of what I'm trying to do. I want to add the this in my add new post.
Right now I've to select the key value whenever a new post is created. I want something similar to the image attached in my add new post. Thanks.
You can use native WordPress function(s) to do the same thing. Of course, you lose the extensive ACF features and slick ACF admin panels.
Instead of using ACF's get_field(), you can use get_post_meta(get_the_ID(), 'field', true);
List all items in the meta field 'appartments' like so:
$meta_name = 'appartments';
$fields = get_post_meta( $post->ID, $meta_name, true );
foreach ( $fields as $fieldValue )
{
echo $fieldValue . ' ';
}

woo commerce - how to show custom fields on published page

I have set 2 custom fields on the wordpress / woocommerce product page called "imballo" and "sottoimballo" with their values. How do I display these on the published page?
Thanks!
You would have to display the custom fields in the WooCommerce Single Product Page template,
You could do it in two ways,
Add a code in an existing hook of the Product Single page. Check hooks here
Modify the template by overriding it in your WordPress theme. Read here
And in the place where you want to display do the following,
<?php
//Please add your HTML structure as needed.
echo get_post_meta(get_the_ID(), 'imballo');
echo get_post_meta(get_the_ID(), 'sottoimballo');
?>

WordPress Custom Fields get post from page

I'm working on a WordPress website and i have a little problem with the custom fields plugin. I'm familiar with plugin and worked with it few times before.
I created a custom field for posts and a custom field for pages.
When i try to get the page's custom field i get it with no problem.
The page has global $post on top and i do get a different $post->ID
for each post loaded.
$pageMonth = get_field('page-month');
But when i try to get the post's field i get nothing.. I also tried it through
the post's loop with $post->ID
<?php $postMonth = get_field('post-month', $post->ID); ?>
I checked myself few times, the custom field names are fine and i did
attached the post and the page to their custom fields and everything..

Wordpress add property to page

Is it possible to add some kind of "properties" to a Wordpress page? In the admin interface i would like to have a couple of different properties that the page should have to choose from, and then i can "pick up" the value of those properties in my template. Is this possible?
WordPress pages have custom meta values, which can be retrieved in the theme.
In the page editor, you can add meta values by pulling down the "Screen Options" menu at the top-right of the page and checking "Custom Fields". If you do that, a box will show up below the post editor where you can enter custom fields.
You can read more about custom fields (including how to retrieve them from your theme) on the WordPress.org Custom Field documentation page.
http://codex.wordpress.org/Custom_Fields
For example, if you store a "weather" field, you can get it in the theme with something like the following:
<?php
global $post;
echo "Weather: " . get_post_meta($post->ID, 'weather', true);
?>

Resources