Da wir immer mehr mit Onlineshops mit WooCommerce machen und WooCommerce als Shopsystem immer beliebter wird, möchte ich heute über eine wichtige Anpassung schreiben: Die Gestaltung einer eigenen Einzelproduktansicht. Damit meine ich die Ansicht eines einzelnen Produktes samt den Feldern, die es ausmacht.
Kopieren der Woocommerce Templates
Im ersten Schritt müssen die gewünschten Templatedateien aus wp-content/plugins/woocommerce/templates in das eigene Theme oder Child-Theme kopiert werden und zwar in ein Unterverzeichnis des Themeverzeichnisses.
Dateien wie:
archive-product.php
single-product.php
taxonomy-product_cat.php
werden in das Verzeichnis wp-content/themes/<DeinTheme>/woocommerce/ kopiert und schon kann man die Ansichten anpassen ohne durch kleinere WooCommerce Updates Probleme erwarten zu müssen.
Anpassen der Hooks
Ein konkretes Beispiel: Vor jedem Preis soll der Text „Ab“ erscheinen – d.h. anstatt 39€ soll Ab 39€ stehen.
Dafür öffne ich die single-product.php, welche auf die content-single-product.php verweist. Dort finde ich den passenden Hook namens woocommerce_single_product_summary der die Funktion woocommerce_template_single_price aufruft, welche ich nutzen möchte um vor den Preis den Text „Ab“ zu schreiben.
<?php /** * woocommerce_single_product_summary hook * * @hooked woocommerce_template_single_title - 5 * @hooked woocommerce_template_single_rating - 10 * @hooked woocommerce_template_single_price - 10 * @hooked woocommerce_template_single_excerpt - 20 * @hooked woocommerce_template_single_add_to_cart - 30 * @hooked woocommerce_template_single_meta - 40 * @hooked woocommerce_template_single_sharing - 50 */ do_action( 'woocommerce_single_product_summary' ); ?>
Um die Anzeige des Preises zu verändern entferne ich zuerst die bestehende Funktion woocommerce_template_single_price aus der Liste der Funktionen, die durch das Ausführen des Hooks woocommerce_single_product_summary aufgerufen werden. Den folgenden Code kann man in die functions.php des eigenen Themes schreiben.
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
Danach binde ich meine eigen neue Funktion namens starting_price an den Hook woocommerce_single_product_summary. Damit sieht der Code in der functions.php folgendermaßen aus.
add_action( 'woocommerce_single_product_summary', 'starting_price', 10 );
Jetzt noch die Funktion starting_code und schon sieht die functions.php so aus:
function starting_price( ) { global $post, $product; echo '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">'; echo '<p class="price">' . __( 'Ab ', 'woocommerce' ) . $product->get_price_html() . '</p>'; echo '<meta itemprop="price" content="' . $product->get_price() . '" />'; echo '<meta itemprop="priceCurrency" content="' . get_woocommerce_currency() . '" />'; echo '</div>'; }
Der Code für diese Funktion kommt aus der price.php aus dem wp-content/plugins/woocommerce/templates/single-product Ordner. Die einzige Änderung ist die Ausgabe von ‚Ab‘:
echo '<p class="price">' . __( 'Ab ', 'woocommerce' ) . $product->get_price_html() . '</p>';
Die Änderung sieht im Frontend dann wie folgt aus:
[one_half first]Vorher
[/one_half]
[one_half]Nachher
[/one_half]
Ich hoffe diese kurze Anleitung gibt die notwendigen Hinweise für eine eigene Anpassung von WooCommerce die auch nach einem Plugin-Update erhalten bleibt.
buying from online mexican pharmacy: Online Pharmacies in Mexico – buying prescription drugs in mexico
best india pharmacy http://indiaph24.store/# reputable indian online pharmacy
india online pharmacy
https://indiaph24.store/# reputable indian online pharmacy
canadian pharmacy ed medications [url=https://canadaph24.pro/#]Certified Canadian Pharmacies[/url] onlinecanadianpharmacy 24
top 10 pharmacies in india [url=https://indiaph24.store/#]Generic Medicine India to USA[/url] top 10 online pharmacy in india
http://canadaph24.pro/# canadian pharmacy world
https://cytotec.club/# buy cytotec over the counter
cipro: buy cipro online – cipro pharmacy
buy cytotec [url=http://cytotec.club/#]cytotec pills buy online[/url] buy cytotec over the counter
http://finasteride.store/# order generic propecia pills
ciprofloxacin 500 mg tablet price [url=http://ciprofloxacin.tech/#]buy ciprofloxacin[/url] buy cipro online canada
https://ciprofloxacin.tech/# cipro 500mg best prices
does tamoxifen make you tired [url=https://nolvadex.life/#]how to lose weight on tamoxifen[/url] nolvadex steroids
lisinopril 1.25 mg: lisinopril 40 mg prices – lisinopril brand name in india
http://lisinopril.network/# buy lisinopril 20 mg without a prescription
tamoxifen rash pictures [url=https://nolvadex.life/#]tamoxifen and weight loss[/url] tamoxifen and osteoporosis
get generic propecia: order propecia for sale – buy propecia no prescription
http://finasteride.store/# cost propecia without a prescription
http://finasteride.store/# buying propecia pill
buying propecia without insurance [url=https://finasteride.store/#]buy propecia price[/url] buying generic propecia for sale
http://nolvadex.life/# tamoxifen hot flashes
buy cytotec [url=https://cytotec.club/#]order cytotec online[/url] buy misoprostol over the counter
buy cytotec in usa: buy misoprostol over the counter – cytotec pills buy online
http://cytotec.club/# buy cytotec
nolvadex 20mg [url=https://nolvadex.life/#]does tamoxifen cause joint pain[/url] tamoxifen rash pictures
buy cytotec online fast delivery [url=https://cytotec.club/#]Abortion pills online[/url] buy cytotec over the counter
https://nolvadex.life/# how to prevent hair loss while on tamoxifen
https://finasteride.store/# cheap propecia price
http://finasteride.store/# cheap propecia without a prescription
tamoxifen cyp2d6 [url=http://nolvadex.life/#]hysterectomy after breast cancer tamoxifen[/url] femara vs tamoxifen
cytotec abortion pill [url=https://cytotec.club/#]buy cytotec online[/url] buy cytotec over the counter
http://finasteride.store/# cost of cheap propecia pill
Cytotec 200mcg price: cytotec pills buy online – Cytotec 200mcg price
cytotec abortion pill [url=https://cytotec.club/#]buy misoprostol over the counter[/url] buy cytotec
http://cytotec.club/# buy cytotec over the counter
lisinopril 40 mg purchase: lisinopril 5 mg canada – best lisinopril brand
pct nolvadex [url=https://nolvadex.life/#]is nolvadex legal[/url] low dose tamoxifen
https://nolvadex.life/# tamoxifen endometrium
https://ciprofloxacin.tech/# ciprofloxacin generic
lisinopril 20 mg cost [url=http://lisinopril.network/#]lisinopril 20 mg canadian[/url] lisinopril 40 mg daily
http://nolvadex.life/# nolvadex for sale
cytotec buy online usa: cytotec abortion pill – buy cytotec over the counter
propecia tablet [url=https://finasteride.store/#]order propecia no prescription[/url] order cheap propecia without prescription
https://finasteride.store/# buying generic propecia price
ciprofloxacin order online: ciprofloxacin – antibiotics cipro
order propecia pills [url=http://finasteride.store/#]buy cheap propecia pill[/url] cheap propecia
https://nolvadex.life/# how does tamoxifen work
https://lisinopril.network/# cost of brand name lisinopril
buy cytotec pills [url=https://cytotec.club/#]cytotec abortion pill[/url] order cytotec online
lisinopril 2.5 mg coupon: zestoretic 20 12.5 mg – cost of lisinopril 5 mg
https://ciprofloxacin.tech/# ciprofloxacin 500mg buy online
lisinopril 5 mg canada [url=http://lisinopril.network/#]lisinopril 10 mg for sale without prescription[/url] cost of lisinopril 10 mg
buy cytotec [url=http://cytotec.club/#]cytotec buy online usa[/url] Abortion pills online
https://lisinopril.network/# lisinopril 80 mg
tamoxifen and weight loss: arimidex vs tamoxifen bodybuilding – effexor and tamoxifen
https://cialist.pro/# Buy Tadalafil 10mg
Cheap Levitra online: Buy generic Levitra online – Buy generic Levitra online
Generic Levitra 20mg [url=https://levitrav.store/#]Levitra 20mg price[/url] Levitra 10 mg best price
http://viagras.online/# Cheap generic Viagra
http://viagras.online/# Cheapest Sildenafil online
cheap kamagra [url=https://kamagra.win/#]kamagra oral jelly[/url] Kamagra tablets
Buy Vardenafil 20mg: Cheap Levitra online – Levitra 20 mg for sale
https://viagras.online/# sildenafil online
Cheap Levitra online: Levitra generic price – Buy Vardenafil 20mg
Generic Viagra for sale [url=https://viagras.online/#]Buy Viagra online cheap[/url] cheapest viagra
kamagra: buy kamagra online – cheap kamagra
http://kamagra.win/# п»їkamagra
https://viagras.online/# sildenafil 50 mg price
Cenforce 100mg tablets for sale [url=http://cenforce.pro/#]Cenforce 100mg tablets for sale[/url] Buy Cenforce 100mg Online
Cheap generic Viagra online: Buy generic 100mg Viagra online – Viagra Tablet price
http://kamagra.win/# Kamagra 100mg
sildenafil 50 mg price [url=http://viagras.online/#]Viagra online price[/url] Generic Viagra online
Generic Levitra 20mg: Buy generic Levitra online – Buy Vardenafil 20mg
Cheap Viagra 100mg: Cheapest place to buy Viagra – sildenafil 50 mg price
http://kamagra.win/# п»їkamagra
Buy Tadalafil 20mg [url=https://cialist.pro/#]buy cialis online[/url] Generic Cialis price
http://levitrav.store/# Levitra generic best price
https://levitrav.store/# buy Levitra over the counter
Tadalafil Tablet: Cialis 20mg price in USA – Buy Tadalafil 20mg
Sildenafil Citrate Tablets 100mg [url=http://viagras.online/#]Buy Viagra online[/url] best price for viagra 100mg
https://cialist.pro/# Cialis without a doctor prescription
mexico online pharmacy prescription drugs: buy meds online no prescription – buy medication online no prescription
quality prescription drugs canada [url=https://pharmnoprescription.icu/#]no prescription[/url] online canadian pharmacy no prescription
https://pharmindia.online/# best online pharmacy india
indianpharmacy com [url=http://pharmindia.online/#]best india pharmacy[/url] indianpharmacy com
best india pharmacy: indianpharmacy com – reputable indian online pharmacy
buy medications online no prescription: no prescription online pharmacy – buy medication online no prescription
https://pharmindia.online/# reputable indian pharmacies