Tell us what you are trying to do?
I've created some custom fields which is used to add information to Woocommerce products. Now I want the info from some of these fields to be showned in the order confirmation email. I belive the correct way for this is to create custom placeholders for these fields.
I came across following guide,which describe how to create custom placeholders: hidden link
But, this guide only show how to create placeholders from woocommerce default product information. Can someone point me in the correct direction how to create placeholder from product information made out of Toolset custom fields?
Hello. Thank you for contacting the Toolset support.
With the reference link you shared - there is a link " WooCommerce order object here" when you click on that link you will be landed on the following page that shows how you can loop through the products added to the order:
- hidden link
I see the following code available with the above link to loop through the products added to order:
// Get and Loop Over Order Items
foreach ( $order->get_items() as $item_id => $item ) {
$product_id = $item->get_product_id();
$variation_id = $item->get_variation_id();
$product = $item->get_product(); // see link above to get $product info
$product_name = $item->get_name();
$quantity = $item->get_quantity();
$subtotal = $item->get_subtotal();
$total = $item->get_total();
$tax = $item->get_subtotal_tax();
$tax_class = $item->get_tax_class();
$tax_status = $item->get_tax_status();
$allmeta = $item->get_meta_data();
$somemeta = $item->get_meta( '_whatever', true );
$item_type = $item->get_type(); // e.g. "line_item", "fee"
}
Once you have product ID - you can use the native WrodPress function get_post_meta(), for instance:
If you have created the custom field with slug "bookname" then it will be stored in the postmeta table with the key "wpcf-bookname". To get its value, you can use:
The first code is to get the Product ID from the Order, right? What changes do I have to make in it to fit my me?
The second code is to get the value out of the custom field, what changes to I have to make? Can add more then one field , e.g.:
$product_id = $item->get_product_id();
$book_name = get_post_meta($product_id, 'wpcf-bookname, ', true);
$dvd_name = get_post_meta($product_id, 'wpcf-dvd', true);
$video_name = get_post_meta($product_id, 'wpcf-video', true);
Is it the slug for the custom field I then use as placeholder e.g. {wpch-bookname}?
When there will be multiple products added to single order - how you want to display the placeholder and for what custom fields you want to display the placeholder?
Can you please share problem URL as well as admin access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
When I try to access the wp-admin to login to admin panel:
I can see its showing the following messages:
SK
Z dôvodu ochrany hostingov pred opakujúcimi útokmi sme boli nútení pre vybrané krajiny obmedziť prístup do administratívneho rozhrania webových stránok. Pokiaľ potrebujete s administráciou pracovať zo zahraničia, prosím prihláste sa do Webadminu, prejdite do správy domény a v sekcii "CMS - redakčné systémy" kliknite na "Vypnúť geoip filter".
EN
Due to protection of web servers from repeated attacks, we were forced to restrict access to administrative interface of web pages to selected countries. If you are currently in a foreign country, please sign in to WebAdmin, proceed to your domain management and disable this GeoIP filter in CMS section.
CZ
Z důvodu ochrany webhostingů před opakujícími se útoky jsme byli nuceni pro vybrané země omezit přístup do administračního rozhraní webových stránek. Pokud potřebujete s administrací pracovat ze zahraničí, prosíme, přihlašte se do WebAdminu, přejděte do správy domény a v sekci "CMS - redakční systémy" klikněte na "Vypnout geoip filtr".
HU
Szervereink védelme érdekében az ismételt támadások ellen kénytelenek voltunk blokkolni a "CMS - tartalomkezelő rendszerek" admin felületére szóló bejelentkezést bizonyos országokból. Részletes információkért keresse ügyfélszolgálatunkat a helpdesk@webonic.hu címen vagy a (06) 1 501 49 49-es telefonszámon. Köszönjük a megértést!
Can you please lift the restrictions and also tell me what is the problem URL and where I can see the filter hook code you added.
I have set the next reply to private which means only you and I have access to it.