<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>anzeigen Archiv - Homepage nach Preis - Webseite erstellen lassen</title>
	<atom:link href="https://homepage-nach-preis.de/wort/anzeigen/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>★ Responsive Webdesigner Homepage erstellen lassen, bereits ab 299 Euro professionelle Webseite. ✓ Google-Optimiert ✓ Mobil-Optimiert &#124; Webdesign &#38; Seo</description>
	<lastBuildDate>Thu, 23 May 2024 15:13:45 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://homepage-nach-preis.de/wp-content/uploads/2021/02/cropped-icon-150x150.png</url>
	<title>anzeigen Archiv - Homepage nach Preis - Webseite erstellen lassen</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>WooCommerce individuelles Badge erstellen</title>
		<link>https://homepage-nach-preis.de/2023/05/27/woocommerce-individuelles-badge-erstellen/</link>
					<comments>https://homepage-nach-preis.de/2023/05/27/woocommerce-individuelles-badge-erstellen/#respond</comments>
		
		<dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
		<pubDate>Sat, 27 May 2023 19:04:12 +0000</pubDate>
				<category><![CDATA[Onlineshop]]></category>
		<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[Wordpress Code]]></category>
		<category><![CDATA[anzeigen]]></category>
		<category><![CDATA[Badge]]></category>
		<category><![CDATA[Funktion]]></category>
		<category><![CDATA[Neu]]></category>
		<category><![CDATA[Shortcode]]></category>
		<category><![CDATA[WooCommere]]></category>
		<guid isPermaLink="false">https://homepage-nach-preis.de/?p=7714</guid>

					<description><![CDATA[<p>Individuelle zeitbasierte Badges erstellen für WooCommerce Mit diesem Code, welcher in die functions.php (im Theme-Verzeichnis von WordPress) eingefügt wird, können eigene Badges für Produkte erstellt und angezeigt werden. Funktionsübersicht Version 1: &#8211; Erstellt ein Badge basierend auf dem Erstellungsdatum des Produktes &#8211; Das Badge beinhaltet das Wort &#8220;NEU&#8221; und wird angezeigt, wenn ein Produkt innerhalb der letzten 3 Tage erstellt wurde &#8211; Die Position des Badges kann durch ein Shortcode bestimmt werden Funktionsübersicht Version 2: &#8211; Erstellt ein Badge basierend auf dem Erstellungs- und Modifikationsdatum des Produktes &#8211; Das Badge beinhaltet das Wort &#8220;NEU&#8221; und wird angezeigt, wenn ein Produkt innerhalb der letzten 3 Tage erstellt wurde &#8211; Wenn das Produkt nicht innerhalb der letzten 3 Tage erstellt wurde, wird ein Badge mit dem Word &#8220;Aktualisiert&#8221; angezeigt werden, falls das Produkt innerhalb der letzten 3 Tage aktualisiert wurde &#8211; Die Position des Badges kann durch ein Shortcode bestimmt werden Version 1: /** * WooCommerce Badge New * @since 1.0.0 */ add_action( &#x27;woocommerce_before_shop_loop_item_title&#x27;, &#x27;hnp_new_badge&#x27;, 3 ); function hnp_new_badge() { &#x9; global $product; $newness_days = 1; $created = strtotime( $product-&#x3E;get_date_created() ); if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) &#x3C; $created ) { echo &#x27;&#x3C;div....</p>
<p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2023/05/27/woocommerce-individuelles-badge-erstellen/">WooCommerce individuelles Badge erstellen</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Individuelle zeitbasierte Badges erstellen für WooCommerce</h3>
<p>Mit diesem Code, welcher in die functions.php (im Theme-Verzeichnis von WordPress) eingefügt wird, können eigene Badges für Produkte erstellt und angezeigt werden.</p>
<p><strong>Funktionsübersicht Version 1: </strong><br />
&#8211; Erstellt ein Badge basierend auf dem Erstellungsdatum des Produktes<br />
&#8211; Das Badge beinhaltet das Wort &#8220;NEU&#8221; und wird angezeigt, wenn ein Produkt innerhalb der letzten 3 Tage erstellt wurde<br />
&#8211; Die Position des Badges kann durch ein Shortcode bestimmt werden</p>
<p><strong>Funktionsübersicht Version 2: </strong><br />
&#8211; Erstellt ein Badge basierend auf dem Erstellungs- und Modifikationsdatum des Produktes<br />
&#8211; Das Badge beinhaltet das Wort &#8220;NEU&#8221; und wird angezeigt, wenn ein Produkt innerhalb der letzten 3 Tage erstellt wurde<br />
&#8211; Wenn das Produkt nicht innerhalb der letzten 3 Tage erstellt wurde, wird ein Badge mit dem Word &#8220;Aktualisiert&#8221; angezeigt werden, falls das Produkt innerhalb der letzten 3 Tage aktualisiert wurde<br />
&#8211; Die Position des Badges kann durch ein Shortcode bestimmt werden</p>
<p>Version 1: </p>
<pre>/**
 * WooCommerce Badge New
 * @since 1.0.0
 */

add_action( &#x27;woocommerce_before_shop_loop_item_title&#x27;, &#x27;hnp_new_badge&#x27;, 3 );
          
function hnp_new_badge() {
&#x9;
   global $product;
   $newness_days = 1;
   $created = strtotime( $product-&#x3E;get_date_created() );
   
   if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) &#x3C; $created ) {
      echo &#x27;&#x3C;div class=&#x22;hnp_new_badge&#x22;&#x3E;Neu&#x3C;/div&#x3E;&#x27;;
   }
}


/**
 * Custom Shortcode
 * @since 1.0.0
 */


function hnp_badge_short() {
     return hnp_new_badge();
 } 

add_shortcode( &#x27;hnp_shortcode_badge&#x27;, &#x27;hnp_badge_short&#x27; );

</pre>
<p>Version 2: </p>
<pre>


/**
 * WooCommerce Badge New and Updated
 * @since 1.0.0
 */

add_action( &#x27;woocommerce_before_shop_loop_item_title&#x27;, &#x27;hnp_new_badge&#x27;, 3 );
          
function hnp_new_badge() {
&#x9;
   global $product;
   $newness_days = 1;
   $update_days = 1;
   $created = strtotime( $product-&#x3E;get_date_created() );
   $modify = strtotime( $product-&#x3E;get_date_modified() );
   
   if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) &#x3C; $created ) {
      echo &#x27;&#x3C;div class=&#x22;hnp_new_badge&#x22;&#x3E;Neu&#x3C;/div&#x3E;&#x27;;
   }
   else
   {
       if ( ( time() - ( 60 * 60 * 24 * $update_days  ) ) &#x3C; $modify ) {
           echo &#x27;&#x3C;div class=&#x22;hnp_upd_badge&#x22;&#x3E;Aktualisiert&#x3C;/div&#x3E;&#x27;;
         }  
   }
}

/**
 * Custom Shortcode
 * @since 1.0.0
 */


function hnp_badge_short() {
     return hnp_new_badge();
 } 

add_shortcode( &#x27;hnp_shortcode_badge&#x27;, &#x27;hnp_badge_short&#x27; );

</pre>
<p><strong>Das Shortcode für die Frontend-Anzeige ist:</strong></p>
<pre>[hnp_shortcode_badge]</pre>
<p>Das Shortcode kann in Widgets, Produktbeschreibungen, Texteditoren oder bei anderen Nutzungsmöglichkeiten (z.B. Pagebuildern) genutzt werden. Sollte das Shortcode in eine HTML-Datei eingefügt werden, wäre der passende Code: </p>
<pre>&#x3C;?php echo do_shortcode(&#x27;[hnp_shortcode_badge]&#x27;); ?&#x3E;</pre>
<p>Sollte das Shortcode in eine PHP Datei (mit geöffneten PHP Tag) eingebunden werden, wäre der Code: </p>
<pre>echo do_shortcode(&#x27;[hnp_shortcode_badge]&#x27;); </pre>
<p><strong>Weitere mögliche Modifikationen: </strong><br />
1. Dauer der Badge-Anzeige ändern<br />
Um die Dauer der Anzeige zu verändern, werden folgende Zeilen verändert, die Zahlen nach dem &#8220;=&#8221; sind die Tage. </p>
<pre>   $newness_days = 1;
   $update_days = 1;</pre>
<p>2. Worte austauschen<br />
Um die Worte &#8220;Neu&#8221; oder &#8220;aktualisiert&#8221; auszutauschen, werden folgende Zeilen angepasst:</p>
<pre>echo &#x27;&#x3C;div class=&#x22;hnp_new_badge&#x22;&#x3E;Neu&#x3C;/div&#x3E;&#x27;;
echo &#x27;&#x3C;div class=&#x22;hnp_upd_badge&#x22;&#x3E;Aktualisiert&#x3C;/div&#x3E;&#x27;;</pre>
<p>Die &#8221; müssen bestehen bleiben. </p>
<p>3. Andere Trigger nutzen<br />
Die aktuellen Trigger-Werte sind: </p>
<pre>$product->get_date_created
$product->get_date_modified</pre>
<p>Hierbei weitere mögliche Trigger-Werte:</p>
<pre>/**
 *
 *  General Product Data
 *
 */
$product->get_id(); // Returns the unique ID for this object.
$product->get_description(); // Get product description.
$product->get_formatted_name(); // Get product name with SKU or ID. Used within admin.
$product->get_featured(); // If the product is featured.
$product->get_name(); // Get product name.
$product->get_title(); // Get the product's title. For products this is the product name.
$product->get_type(); // Get internal type. Should return string and *should be overridden* by child classes.
$product->get_virtual(); // Get virtual.
$product->get_total_sales(); // Get number total of sales.
$product->get_short_description(); // Get product short description.
$product->get_sku(); // Get SKU (Stock-keeping unit) - product unique ID.
$product->get_slug(); // Get product slug.
$product->get_status(); // Get product status.
$product->get_permalink(); // Product permalink.
$product->get_catalog_visibility(); // Get catalog visibility.

/**
 *
 *  Pricing Data
 *
 */
$product->get_price(); // Returns the product's active price.
$product->get_date_on_sale_from(); // Get date on sale from.
$product->get_date_on_sale_to(); // Get date on sale to.
$product->get_display_price(); // Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
$product->get_price_excluding_tax(); // Returns the price (excluding tax) - ignores tax_class filters since the price may *include* tax and thus needs subtracting.
$product->get_price_html(); // Returns the price in html format.
$product->get_price_html_from_text(); // Functions for getting parts of a price, in html, used by $product->get_price_html.
$product->get_price_html_from_to(); // Functions for getting parts of a price, in html, used by $product->get_price_html.
$product->get_price_including_tax(); // Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes.
$product->get_price_suffix(); // Get the suffix to display after prices > 0.
$product->get_sale_price(); // Returns the product's sale price.
$product->get_regular_price(); // Returns the product's regular price.
$product->get_tax_class(); // Returns the tax class.
$product->get_tax_status(); // Returns the tax status.

/**
 *
 *  Image Related Data
 *
 */
$product->get_image(); // Returns the main product image.
$product->get_image_id(); // Get main image ID.
$product->get_gallery_attachment_ids(); // Returns the gallery attachment ids.
$product->get_gallery_image_ids(); // Returns the gallery attachment ids.

/**
 *
 *  Stock or Inventory Data
 *
 */
$product->get_backorders(); // Get backorders.
$product->get_availability(); // Returns the availability of the product.
$product->get_max_purchase_quantity(); // Get max quantity which can be purchased at once.
$product->get_min_purchase_quantity(); // Get min quantity which can be purchased at once.
$product->get_stock_managed_by_id(); // If the stock level comes from another product ID, this should be modified.
$product->get_stock_quantity(); // Returns number of items available for sale.
$product->get_stock_status(); // Return the stock status.
$product->get_total_stock(); // Get total stock - This is the stock of parent and children combined.
$product->get_sold_individually(); // Return if should be sold individually.
$product->get_low_stock_amount(); // Get low stock amount.

/**
 *
 *  Shipping Data
 *
 */
$product->get_height(); // Returns the product height.
$product->get_length(); // Returns the product length.
$product->get_weight(); // Returns the product's weight.
$product->get_width(); // Returns the product width.
$product->get_dimensions(); // Returns formatted dimensions.
$product->get_manage_stock(); // Return if product manage stock.
$product->get_shipping_class(); // Returns the product shipping class SLUG.
$product->get_shipping_class_id(); // Get shipping class ID.

/**
 *
 *  Product Variations / Parent Data
 *
 */
$product->get_child(); // Returns the child product.
$product->get_children(); // Returns the children IDs if applicable. Overridden by child classes.
$product->get_formatted_variation_attributes(); // Get formatted variation data with WC < 2.4 back compat and proper formatting of text-based attribute names.
$product->get_matching_variation(); // Match a variation to a given set of attributes using a WP_Query.
$product->get_parent(); // Get the parent of the post.
$product->get_parent_id(); // Get parent ID.
$product->get_variation_default_attributes(); // If set, get the default attributes for a variable product.
$product->get_variation_description(); // Get product variation description.
$product->get_variation_id(); // Get variation ID.

/**
 *
 *  Product Downloads
 *
 */
$product->get_download_expiry(); // Get download expiry.
$product->get_download_limit(); // Get download limit.
$product->get_downloadable(); // Get downloadable.
$product->get_downloads(); // Get downloads.
$product->get_file(); // Get a file by $download_id.
$product->get_file_download_path(); // Get file download path identified by $download_id.
$product->get_files(); // Same as $product->get_downloads in CRUD.

/**
 *
 *  Attributes, Tags, Categories & Associated Data Objects
 *
 */
$product->get_attribute(); // Returns a single product attribute as a string.
$product->get_attributes(); // Returns product attributes.
$product->get_categories(); // Returns the product categories.
$product->get_category_ids(); // Get category ids.
$product->get_default_attributes(); // Get default attributes.
$product->get_cross_sell_ids(); // Get cross sell IDs.
$product->get_cross_sells(); // Returns the cross sell product ids.
$product->get_related(); // Get and return related products.
$product->get_tag_ids(); // Get tag ids.
$product->get_tags(); // Returns the product tags.
$product->get_upsell_ids(); // Get upsell IDs.
$product->get_upsells(); // Returns the upsell product ids.
$product->get_meta(); // Get Meta Data by Key.
$product->get_meta_data(); // Get All Meta Data.

/**
 *
 *  Ratings and Reviews
 *
 */
$product->get_rating_count(); // Get the total amount (COUNT) of ratings, or just the count for one rating e.g. number of 5 star ratings.
$product->get_rating_counts(); // Get rating count.
$product->get_rating_html(); // Returns the product rating in html format.
$product->get_review_count(); // Get review count.
$product->get_reviews_allowed(); // Return if reviews is allowed.
$product->get_average_rating(); // Get average rating.

/**
 *
 *  Other Product Data
 *
 */
$product->get_changes(); // Return data changes only.
$product->get_data(); // Returns all data for this object.
$product->get_data_keys(); // Returns array of expected data keys for this object.
$product->get_data_store(); // Get the data store.
$product->get_date_created(); // Get product created date.
$product->get_date_modified(); // Get product modified date.
$product->get_extra_data_keys(); // Returns all "extra" data keys for an object (for sub objects like product types).
$product->get_menu_order(); // Get menu order.
$product->get_meta_cache_key(); // Helper method to compute meta cache key. Different from WP Meta cache key in that meta data cached using this key also contains meta_id column.
$product->get_object_read(); // Get object read property.
$product->get_post_data(); // Get the product's post data.
$product->get_post_password(); // Get post password.
$product->get_purchase_note(); // Get purchase note.</pre>
<h5>Responsive Webseite von Webdesigner erstellen lassen? <a href="https://homepage-nach-preis.de/homepage-erstellen-lassen-kosten/" Title="Responsive Website erstellen lassen"><font color="orange">WEBDESIGN ANGEBOTE ANSEHEN</font></a></h5>
<p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2023/05/27/woocommerce-individuelles-badge-erstellen/">WooCommerce individuelles Badge erstellen</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://homepage-nach-preis.de/2023/05/27/woocommerce-individuelles-badge-erstellen/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Custom Felder bei WooCommerce Produkte</title>
		<link>https://homepage-nach-preis.de/2023/05/27/custom-felder-bei-woocommerce-produkte/</link>
					<comments>https://homepage-nach-preis.de/2023/05/27/custom-felder-bei-woocommerce-produkte/#respond</comments>
		
		<dc:creator><![CDATA[Homepage-nach-Preis]]></dc:creator>
		<pubDate>Sat, 27 May 2023 13:21:50 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[Wordpress Code]]></category>
		<category><![CDATA[anzeigen]]></category>
		<category><![CDATA[Felder]]></category>
		<category><![CDATA[Informationen]]></category>
		<category><![CDATA[Produkt]]></category>
		<category><![CDATA[Shortcode]]></category>
		<category><![CDATA[Woocommerce]]></category>
		<guid isPermaLink="false">https://homepage-nach-preis.de/?p=7673</guid>

					<description><![CDATA[<p>Individuelle WooCommerce Input &#038; Output Felder erzeugen Dieser Code erweitert die WooCommerce Produktseiten mit einem individuellen Eingabe-Text-Feld. Die eingegebenen Daten werden anschließend im Frontend der Produktseite ausgegeben. Der Code muss in die Functions.php, im Hauptverzeichnis des WordPress-Themes, eingefügt werden. Funktionsumfang: &#8211; Erzeugt ein Text-Input-Feld im Backend der WooCommerce Produkte (global, bei allen Produkten) &#8211; Speichert die Daten des Input-Feldes bei Aktualisierung des Produktes (Getrennte Daten für jedes Produkt) &#8211; Anzeige der gespeicherten Daten im Frontend des WooCommerce Produktes &#8212; Anzeige standardmäßig direkt über dem Warenkorb-Button /** * Custom Field / Info in a Woocommerce Product * @since 1.0.0 */ /** * Display the custom field on the front end of a Woocommerce product * @since 1.0.0 */ function hnp_display_custom_field_1() { global $post; // Check for the custom field value $product = wc_get_product($post-&#x3E;ID); $title = $product-&#x3E;get_meta(&#x27;hnp_custom_text_field_title_1&#x27;); if ($title) { // Only display our field if we&#x27;ve got a value for the field title printf(&#x27;%s&#x27;, esc_html($title)); } } add_action(&#x27;woocommerce_before_add_to_cart_button&#x27;, &#x27;hnp_display_custom_field_1&#x27;); /** * Create the custom text input field in the Backend of a Woocommerce Product * @since 1.0.0 */ function hnp_hnp_create_custom_field_1() { $args = array( &#x27;id&#x27; =&#x3E; &#x27;hnp_custom_text_field_title_1&#x27;, &#x27;label&#x27; =&#x3E; __(&#x27;Custom Field&#x27;, &#x27;hnp&#x27;) , &#x27;class&#x27; =&#x3E; &#x27;hnp-custom-field&#x27;, &#x27;desc_tip&#x27; =&#x3E; true, &#x27;description&#x27; =&#x3E;....</p>
<p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2023/05/27/custom-felder-bei-woocommerce-produkte/">Custom Felder bei WooCommerce Produkte</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Individuelle WooCommerce Input &#038; Output Felder erzeugen</h3>
<p>Dieser Code erweitert die WooCommerce Produktseiten mit einem individuellen Eingabe-Text-Feld. Die eingegebenen Daten werden anschließend im Frontend der Produktseite ausgegeben. Der Code muss in die Functions.php, im Hauptverzeichnis des WordPress-Themes, eingefügt werden. </p>
<p><strong>Funktionsumfang:</strong></p>
<p>&#8211; Erzeugt ein Text-Input-Feld im Backend der WooCommerce Produkte (global, bei allen Produkten)</p>
<p>&#8211; Speichert die Daten des Input-Feldes bei Aktualisierung des Produktes (Getrennte Daten für jedes Produkt)</p>
<p>&#8211; Anzeige der gespeicherten Daten im Frontend des WooCommerce Produktes<br />
&#8212; Anzeige standardmäßig direkt über dem Warenkorb-Button</p>
<pre>


/**
 * Custom Field / Info in a Woocommerce Product
 * @since 1.0.0
 */

/**
 * Display the custom field on the front end of a Woocommerce product
 * @since 1.0.0
 */

function hnp_display_custom_field_1()
{
    global $post;
    // Check for the custom field value
    $product = wc_get_product($post-&#x3E;ID);
    $title = $product-&#x3E;get_meta(&#x27;hnp_custom_text_field_title_1&#x27;);
    if ($title)
    {
        // Only display our field if we&#x27;ve got a value for the field title
        printf(&#x27;%s&#x27;, esc_html($title));
    }
}
add_action(&#x27;woocommerce_before_add_to_cart_button&#x27;, &#x27;hnp_display_custom_field_1&#x27;);

/**
 * Create the custom text input field in the Backend of a Woocommerce Product
 * @since 1.0.0
 */

function hnp_hnp_create_custom_field_1()
{
    $args = array(
        &#x27;id&#x27; =&#x3E; &#x27;hnp_custom_text_field_title_1&#x27;,
        &#x27;label&#x27; =&#x3E; __(&#x27;Custom Field&#x27;, &#x27;hnp&#x27;) ,
        &#x27;class&#x27; =&#x3E; &#x27;hnp-custom-field&#x27;,
        &#x27;desc_tip&#x27; =&#x3E; true,
        &#x27;description&#x27; =&#x3E; __(&#x27;Enter the title of your custom text field.&#x27;, &#x27;chnp&#x27;) ,
    );
    woocommerce_wp_text_input($args);
}
add_action(&#x27;woocommerce_product_options_general_product_data&#x27;, &#x27;hnp_hnp_create_custom_field_1&#x27;);

/**
 * Save the custom field
 * @since 1.0.0
 */
function hnp_save_custom_field_1($post_id)
{
    $product = wc_get_product($post_id);
    $title = isset($_POST[&#x27;hnp_custom_text_field_title_1&#x27;]) ? $_POST[&#x27;hnp_custom_text_field_title_1&#x27;] : &#x27;&#x27;;
    $product-&#x3E;update_meta_data(&#x27;hnp_custom_text_field_title_1&#x27;, sanitize_text_field($title));
    $product-&#x3E;save();
}
add_action(&#x27;woocommerce_process_product_meta&#x27;, &#x27;hnp_save_custom_field_1&#x27;);




</pre>
<p>Wenn im Backend keine Daten im Input-Feld eingetragen wurden, ist die Funktion und die Frontend-Ausgabe nicht aktiv. Somit kann entschieden werden, bei welchen Produkten die Funktion aktiviert und ausgegeben wird.<br />
Information: Es sollte mehr als ein Feld pro Produkt genutzt werden? Dazu muss lediglich die Zahl &#8220;1&#8221; im kompletten Code zu &#8220;2&#8221; geändert werden. Und der Code ein zweites Mal in die Funktions.php eingefügt werden. Der Code kann beliebig oft genutzt werden, sofern jeweils die Zahl pro Nutzung fortlaufend geändert wird.</p>
<p><strong>Erweiterung 1: </strong><br />
Sollte die Frontend-Anzeige noch mit einem Eingabefeld sein, wird Zeile 22: </p>
<pre>printf(&#x27;%s&#x27;, esc_html($title));</pre>
<p>mit diesem Code ausgetauscht: </p>
<pre>printf(&#x27;&#x3C;div class=&#x22;hnp-custom-field-wrapper&#x22;&#x3E;&#x3C;label for=&#x22;hnp-title-field&#x22;&#x3E;%s&#x3C;/label&#x3E;&#x3C;input type=&#x22;text&#x22; id=&#x22;hnp-title-field&#x22; name=&#x22;hnp-title-field&#x22; value=&#x22;&#x22;&#x3E;&#x3C;/div&#x3E;&#x27;, esc_html( $title ));</pre>
<p><strong>Individualisierung 1: </strong><br />
Sollte die Ausgabe des Inputs nicht über dem Warenkorb-Button sein, sondern an einer anderen Position, muss der WooCommerce Hook in Zeile 25</p>
<pre>add_action(&#x27;woocommerce_before_add_to_cart_button&#x27;, &#x27;hnp_display_custom_field_1&#x27;);</pre>
<p>ausgetauscht werden.</p>
<p><strong>Weitere Hooks / Platzierungen (von oben nach unten): </strong></p>
<p>Hook 1: Vor dem Content des Produktes: </p>
<pre>woocommerce_before_single_product</pre>
<p>Hook 2: Vor dem Content des Produktes 2: </p>
<pre>woocommerce_before_single_product_summary</pre>
<p>Hook 3: Nach dem Titel / der Produktüberschrift: </p>
<pre>woocommerce_single_product_summary</pre>
<p>Hook 5: Nach der Kurzbeschreibung:</p>
<pre>woocommerce_before_add_to_cart_form</pre>
<p>Hook 6: Vor den Variationen:</p>
<pre>woocommerce_before_variations_form</pre>
<p>Hook 7: Nach den Variationen:</p>
<pre>woocommerce_before_add_to_cart_button</pre>
<p>Hook 8: Nach den Variationen 2:</p>
<pre>woocommerce_before_single_variation</pre>
<p>Hook 9: Nach der Single Variation:</p>
<pre>woocommerce_single_variation</pre>
<p>Hook 10: Vor der Anzahl-Auswahl:</p>
<pre>woocommerce_before_add_to_cart_quantity</pre>
<p>Hook 11: Nach der Anzahl-Auswahl:</p>
<pre>woocommerce_after_add_to_cart_quantity</pre>
<p>Hook 12: Nach dem Warenkorb Button 1:</p>
<pre>woocommerce_after_single_variation</pre>
<p>Hook 13: Nach dem Warenkorb Button 2:</p>
<pre>woocommerce_after_add_to_cart_button</pre>
<p>Hook 14: Nach dem Warenkorb Button 3:</p>
<pre>woocommerce_after_variations_form</pre>
<p>Hook 15: Nach dem Warenkorb Button 4:</p>
<pre>woocommerce_after_add_to_cart_form</pre>
<p>Hook 16: Vor der Produkt Meta: </p>
<pre>woocommerce_product_meta_start</pre>
<p>Hook 17: Nach der Produkt Meta: </p>
<pre>woocommerce_product_meta_end</pre>
<p>Hook 18: Share / Teilen Area: </p>
<pre>woocommerce_share</pre>
<p>Hook 19: Unter den Produkt-Fotos: </p>
<pre>woocommerce_product_thumbnails</pre>
<p>Hook 20: Am Ende des Produktes: </p>
<pre>woocommerce_after_single_product_summary</pre>
<p>Je nach Theme kann es sein, dass nicht alle Hooks im Design integriert sind oder auch an anderen Positionen angezeigt werden. Durch Ausprobieren oder Auslesen des Theme-Codes sollte aber eine passende Position gefunden werden.</p>
<p><strong>Eigenen Hook erstellen: </strong><br />
Sollten die WooCommerce Standard-Hooks nicht die passende Position bereitstellen, muss ein individueller Hook erstellt werden.</p>
<p>Dazu wird die Zeile 25 auf einen individuellen Hook-Tag geändert:</p>
<pre>add_action(&#x27;hnp_custom_hook_1&#x27;, &#x27;hnp_display_custom_field_1&#x27;);</pre>
<p>Der Hook kann nun in einer gewünschten Stelle im Design eingebunden werden, durch diesen Code:</p>
<pre>&#x3C;?php do_action(&#x27;hnp_custom_hook_1&#x27;);?&#x3E;</pre>
<p>Falls der PhP Tag bereits offen ist: </p>
<pre>do_action(&#x27;hnp_custom_hook_1&#x27;);</pre>
<p><strong>Shortcode anstatt Hook nutzen</strong><br />
Sollte die Funktion nicht automatisch durch einen Hook eingebunden werden, sondern durch ein Shortcode, wird die &#8220;Add Action&#8221; Funktion aus Zeile 25 entfernt und zudem eine Shortcode-Funktion erstellt. Der fertige Code sieht folgend aus:</p>
<pre>
/**
 * Custom Field / Info in a Woocommerce Product
 * @since 1.0.0
 */

/**
 * Display the custom field on the front end of a Woocommerce product
 * @since 1.0.0
 */

function hnp_display_custom_field_1()
{
    global $post;
    // Check for the custom field value
    $product = wc_get_product($post-&#x3E;ID);
    $title = $product-&#x3E;get_meta(&#x27;hnp_custom_text_field_title_1&#x27;);
    if ($title)
    {
        // Only display our field if we&#x27;ve got a value for the field title
        printf(&#x27;%s&#x27;, esc_html($title));
    }
}

/**
 * Create the custom text input field in the Backend of a Woocommerce Product
 * @since 1.0.0
 */

function hnp_hnp_create_custom_field_1()
{
    $args = array(
        &#x27;id&#x27; =&#x3E; &#x27;hnp_custom_text_field_title_1&#x27;,
        &#x27;label&#x27; =&#x3E; __(&#x27;Custom Input&#x27;, &#x27;hnp&#x27;) ,
        &#x27;class&#x27; =&#x3E; &#x27;hnp-custom-field&#x27;,
        &#x27;desc_tip&#x27; =&#x3E; true,
        &#x27;description&#x27; =&#x3E; __(&#x27;Enter the title of your custom text field.&#x27;, &#x27;chnp&#x27;) ,
    );
    woocommerce_wp_text_input($args);
}
add_action(&#x27;woocommerce_product_options_general_product_data&#x27;, &#x27;hnp_hnp_create_custom_field_1&#x27;);

/**
 * Save the custom field
 * @since 1.0.0
 */
function hnp_save_custom_field_1($post_id)
{
    $product = wc_get_product($post_id);
    $title = isset($_POST[&#x27;hnp_custom_text_field_title_1&#x27;]) ? $_POST[&#x27;hnp_custom_text_field_title_1&#x27;] : &#x27;&#x27;;
    $product-&#x3E;update_meta_data(&#x27;hnp_custom_text_field_title_1&#x27;, sanitize_text_field($title));
    $product-&#x3E;save();
}
add_action(&#x27;woocommerce_process_product_meta&#x27;, &#x27;hnp_save_custom_field_1&#x27;);

/**
 * Custom Shortcode
 * @since 1.0.0
 */


function hnp_custom_short1(){
    return hnp_display_custom_field_1();
}

add_shortcode(&#x27;hnp_custom_shortcode_1&#x27;, &#x27;hnp_custom_short1&#x27;); 



</pre>
<p>Auch diese Funktion kann mehrfach genutzt werden, sofern die Zahl &#8220;1&#8221; aus dem kompletten Code ausgetauscht wird. Das Shortcode für die Frontend-Anzeige ist:</p>
<pre>[hnp_custom_shortcode_1]</pre>
<p>Das Shortcode kann in Widgets, Produktbeschreibungen, Texteditoren oder bei anderen Nutzungsmöglichkeiten (z.B. Pagebuildern) genutzt werden. Sollte das Shortcode in eine HTML-Datei eingefügt werden, wäre der passende Code: </p>
<pre>&#x3C;?php echo do_shortcode(&#x27;[hnp_custom_shortcode_1]&#x27;); ?&#x3E;</pre>
<p>Sollte das Shortcode in eine PHP Datei (mit geöffneten PHP Tag) eingebunden werden, wäre der Code: </p>
<pre>echo do_shortcode(&#x27;[hnp_custom_shortcode_1]&#x27;); </pre>
<p><strong>Weitere Möglichkeiten: </strong><br />
Es könnten auch Container, Bilder oder andere HTML Tags für das Frontend eingebunden werden, indem Zeile 25 erweitert wird:</p>
<pre>printf(&#x27;%s&#x27;, esc_html($title));</pre>
<p>Dieser Tag übergibt die eingetragenen Daten des Backends:</p>
<pre>%s</pre>
<p>Hierbei ein Code mit zusätzlich einem Bild und in einem Container: </p>
<pre>  printf(&#x27;&#x3C;div class=&#x22;hnp-container_1&#x22;&#x3E;&#x3C;h3&#x3E;&#xDC;berschrift:&#x3C;/h3&#x3E;&#x3C;p&#x3E;%s&#x3C;/p&#x3E;&#x3C;br&#x3E;&#x3C;img src=&#x22;www.url_zum_bild&#x22; alt=&#x22;alt_tag&#x22; /&#x3E;&#x3C;/div&#x3E;&#x27;, esc_html($title));</pre>
<p>Wenn der Input zusätzlich an die Warenkorbdaten übertragen werden sollen, wäre dies so möglich: </p>
<pre>

/**
 * Custom Field / Info in a Woocommerce Product
 * @since 1.0.0
 */

/**
 * Display the custom field on the front end of a Woocommerce product
 * @since 1.0.0
 */
function hnp_display_custom_field_1() {
    global $post;
    // Check for the custom field value
    $product = wc_get_product($post-&#x3E;ID);
    $title = $product-&#x3E;get_meta(&#x27;hnp_custom_text_field_title_1&#x27;);
    if ($title) {
        // Only display our field if we&#x27;ve got a value for the field title
        printf(&#x27;%s&#x27;, esc_html($title));
    }
}
add_action(&#x27;woocommerce_before_add_to_cart_button&#x27;, &#x27;hnp_display_custom_field_1&#x27;);

/**
 * Create the custom text input field in the Backend of a Woocommerce Product
 * @since 1.0.0
 */
function hnp_hnp_create_custom_field_1() {
    $args = array(
        &#x27;id&#x27; =&#x3E; &#x27;hnp_custom_text_field_title_1&#x27;,
        &#x27;label&#x27; =&#x3E; __(&#x27;Custom Field&#x27;, &#x27;hnp&#x27;),
        &#x27;class&#x27; =&#x3E; &#x27;hnp-custom-field&#x27;,
        &#x27;desc_tip&#x27; =&#x3E; true,
        &#x27;description&#x27; =&#x3E; __(&#x27;Enter the title of your custom text field.&#x27;, &#x27;hnp&#x27;),
    );
    woocommerce_wp_text_input($args);
}
add_action(&#x27;woocommerce_product_options_general_product_data&#x27;, &#x27;hnp_hnp_create_custom_field_1&#x27;);

/**
 * Save the custom field
 * @since 1.0.0
 */
function hnp_save_custom_field_1($post_id) {
    $product = wc_get_product($post_id);
    $title = isset($_POST[&#x27;hnp_custom_text_field_title_1&#x27;]) ? $_POST[&#x27;hnp_custom_text_field_title_1&#x27;] : &#x27;&#x27;;
    $product-&#x3E;update_meta_data(&#x27;hnp_custom_text_field_title_1&#x27;, sanitize_text_field($title));
    $product-&#x3E;save();
}
add_action(&#x27;woocommerce_process_product_meta&#x27;, &#x27;hnp_save_custom_field_1&#x27;);

/**
 * Add custom field value to cart item data
 * @since 1.0.0
 */
function hnp_add_custom_field_to_cart_item($cart_item_data, $product_id) {
    $product = wc_get_product($product_id);
    $custom_field_value = $product-&#x3E;get_meta(&#x27;hnp_custom_text_field_title_1&#x27;);

    if (!empty($custom_field_value)) {
        $cart_item_data[&#x27;hnp_custom_text_field_title_1&#x27;] = $custom_field_value;
    }

    return $cart_item_data;
}
add_filter(&#x27;woocommerce_add_cart_item_data&#x27;, &#x27;hnp_add_custom_field_to_cart_item&#x27;, 10, 2);

/**
 * Display custom field value in the cart
 * @since 1.0.0
 */
function hnp_display_custom_field_in_cart($item_data, $cart_item) {
    if (isset($cart_item[&#x27;hnp_custom_text_field_title_1&#x27;])) {
        $item_data[] = array(
            &#x27;name&#x27; =&#x3E; __(&#x27;Custom Field&#x27;, &#x27;hnp&#x27;),
            &#x27;value&#x27; =&#x3E; $cart_item[&#x27;hnp_custom_text_field_title_1&#x27;]
        );
    }

    return $item_data;
}
add_filter(&#x27;woocommerce_get_item_data&#x27;, &#x27;hnp_display_custom_field_in_cart&#x27;, 10, 2);

/**
 * Save custom field value in cart item meta
 * @since 1.0.0
 */
function hnp_save_custom_field_in_cart_item($item_id, $values, $cart_item_key) {
    if (isset($values[&#x27;hnp_custom_text_field_title_1&#x27;])) {
        wc_add_order_item_meta($item_id, &#x27;hnp_custom_text_field_title_1&#x27;, $values[&#x27;hnp_custom_text_field_title_1&#x27;]);
    }
}
add_action(&#x27;woocommerce_add_order_item_meta&#x27;, &#x27;hnp_save_custom_field_in_cart_item&#x27;, 10, 3);

/**
 * Display custom field value in order items
 * @since 1.0.0
 */
function hnp_display_custom_field_in_order_items($item_id, $item, $order) {
    if ($meta_value = wc_get_order_item_meta($item_id, &#x27;hnp_custom_text_field_title_1&#x27;, true)) {
        echo &#x27;&#x3C;p&#x3E;&#x3C;strong&#x3E;&#x27; . __(&#x27;Custom Field:&#x27;, &#x27;hnp&#x27;) . &#x27;&#x3C;/strong&#x3E; &#x27; . esc_html($meta_value) . &#x27;&#x3C;/p&#x3E;&#x27;;
    }
}
add_action(&#x27;woocommerce_order_item_meta_end&#x27;, &#x27;hnp_display_custom_field_in_order_items&#x27;, 10, 3);


</pre>
<p>Zu beachten ist, dass das Backend-Feld nur mit Text (ohne Code) gefüllt werden sollte, ansonsten könnten Fehler erzeugt werden. Deswegen sollten HTML-Codes ausschließlich über die HTML / PHP Dateien eingebunden werden.<br />
</p>
<h5>Sie wurden gehackt oder Ihre Webseiten mit Viren/Malware infiziert? Wir säubern und schützen Ihre Webseite: <a  href="https://homepage-nach-preis.de/webseite-gehackt-viren-reinigung/" title="Webseite gehackt? Antivirus Service"> <span style="color:#efaa15;">→ Webseiten-Anti-Virus-Service</span></a></h5>
<p>Der Beitrag <a rel="nofollow" href="https://homepage-nach-preis.de/2023/05/27/custom-felder-bei-woocommerce-produkte/">Custom Felder bei WooCommerce Produkte</a> erschien zuerst auf <a rel="nofollow" href="https://homepage-nach-preis.de">Homepage nach Preis - Webseite erstellen lassen</a>. Geschrieben von <a rel="nofollow" href="https://homepage-nach-preis.de/author/homepageadmin/">Homepage-nach-Preis</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://homepage-nach-preis.de/2023/05/27/custom-felder-bei-woocommerce-produkte/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
