In WooCommerce, I would like to display a table on a custom page with a list of (downloadable) products with their title and attribute / custom field values.
For the product title in the first column of my table I'm using the following shortcode:
[product _name id="9"]
The code in my funcions.php file
function displayProductName($item) {
$productName = get_the_title($item['id']);
return $productName;
}
add_shortcode('product_name', 'displayProductName');
In the second column I'd like to display the value of a custom added field (with advanced custom fields): field is File Version (slug file-version), value is 1.22
I can't seem to figure out how to translate this into a working function.
So what I would like is to display the value of a custom field based on a single product ID on a random page with a shortcode.
Any ideas would be very appreciated.
After doing more research, I managed to find the solution, which was much easier than I thought.
Since I'm using Advanced custom Fields, I could use their shortcode.
So for example, I have custom field Download Version (slug: download_version) that I use for downloadable products.
To display the value of Download Version for a specific product, on a random page, I used the shortcode
[acf field="download_version" post_id="9"]
Where the product ID is 9.
Maybe useful for other users who want to do the same...
Related
I am very new to WordPress and I am trying to edit a registration form by adding more fields. When I add a new text field, the product field no longer displays the product and price and just shows the default. I didn't make the website I just need to edit this, I am using the Gravity Forms plugin.
This is the form before editing:
And after adding a new field the product field ( in green writing) reverts to default values:
I can't figure out what makes it change so if you have come across this problem before or have any advice please let me know. Thanks!
I'd bet there is some custom code at play here is that is dependent on the field ID. When you change the field, it has a new ID, and the custom code isn't being applied. I'd suggest doing a full theme/plugin conflict (start with your theme) to see where that custom code resides:
https://docs.gravityforms.com/testing-for-a-themeplugin-conflict/
I'm using Drupal Commerce and i have a product type called "Painting" this product type does not have an attribute fields, I'm using inline_entity_form module so i can show the product add form within the node add form for my product display content type.
The product in the site is the painting itself, it may come with a frame or without a frame (the user can choose) and the price will change based on the user's choice, how can i add such field without using attributes fields? as attributes fields requires that the site admin to add many products and put them in one product display, i just want to keep it simple to the site admin, to make him add the product in the same way he adds a node.
Thank you.
This sounds like you just need two variations:
Product one, without frame
Product two, with frame
Each variation has it's own price and title.
You can get by without using an attribute field. Drupal Commerce renders a dropdown when there are no attributes and allows user's to pick from the product variation titles. Since you are using Inline Entity Form this should be seamless for the site admin.
i am using wordpress 4.1 with ACF v4. I have a custom post type with custom fields added and need add a new custom field each time a new category is added. If i add the category "Sedan" automaticly i have to add the custom field "Sedan". Can I do this with the plugin functions? Or I have to do this with code, with inserts in database? Thanks in advance!!
If you are trying to create a dynamically built category selector within ACF, look into the Taxonomy Field.
This will generate a list based on specified taxonomy (categories is an option). The field will return either the Taxonomy Term object (if you use a single select option such as radio buttons), or an array of objects (if you use a multiselect option such as checkboxes). You could also set the field to return the Term ID instead.
I had Taxonomy category that must had such opportunity to add multiple fields from admin panel and get them like the picture.So for example what i can create that will give the user opportunity to add the fields dynamically and how can I get their values?
I found a solution and used plugin Custom Field Suite
It has a field type Loop and it was what I needed to add how many how needed.
using last versions of wordpress, woocommerce and cheope (theme).
the question: how to
add some extra fields in variations form (text and image field types)
show them on frontend so that their values change accordingly on changing of attributes-select values.
e.g.: the site sells candles and uses variable products, for each kind of candle has several dimensions (with specific different prices), each of which has different duration.
The duration is an important element that I want the user to be informed about.
The same to show the available colors all together.
Unluckily in the standard variation form there is no field where I can insert these or other features.
some help please?
updated 07-August-2013
I succeeded in adding to variations form a new field displayed on back-end, as you can see here, by inserting the code you can find here (please see the comments too) in the function.php file of the theme.
Now, what I’m not able to do is get this field to display with each proper value on front-end (please take a look to the last comment in the above linked page).
Any tip or trick?
thanks
1)Add product attribute and check checkbox Used for variations and Visible on the product page
2)go to variations and add new and fill all fields price and stock must add on them
Your producr display variations and their data