WordPress Bölüm 2 için en iyi WooCommerce görüntülerimden 25
Birkaç gün önce, kullandığım en kullanışlı 25 WooCommerce görüntüsünü dahil ettiğim bir yazı yazdım ve daha fazlasını isteyecek birçok insanıydınız, bu yüzden bugün WooCommerce için birkaç snippet vermeye karar verdim! İşte burada! 1 PayPal Varsayılan WooCommerce/ * * WooCommerce Varsayılan PayPal Icon */ Function PayPal_checkout_icon () {return ‘işlevini değiştirin; // Kendi Resim URL’nizi buraya yazın} add_filter (‘wooocommerce_paypal_icon’, ‘paypal_checkout_icon’); 2 – Yer tutucu görüntüleri değiştirin Varsayılan ürünler / * * tema fonksiyonlarına girer. Php veya özel bir eklenti. Resim dosya adını/ yolunu kendinizle değiştirin 🙂 ***/ add_action (‘init’, ‘Custom_fix_thumbnail’); Custom_fix_thumbnail () {add_filter (‘wooocommerce_placeholder_img_src’, ‘custom_wooocommerce_placeholder_img_src’) işlevi; Custom_wooocommerce_placeholder_img_src ($ src) {$ upload_dir = wp_upload_dir () işlevi; $ uploads = ImprailingsLashite ($ upload_dir [‘Baseurl’]); $ src = $ yükler. ‘/2012/07/thumb1.jpg’; Dönüş $ src; }} 3 – ekmek kırıntılarından “Ürünü” silin / * * WooCommerce ekmek Clumb * / Function Woo_Custom_filter_Breadcrumbs_trail ($ Trail) {foreach ($ trail olarak $ k => $ v) {if (strip_tags ($ v) ) == ‘ürünler’) {unset ($ trail [$ k]); kırmak; }} return $ trail; } add_filter (‘woo_breadcrumbs_trail’, ‘woo_custom_filter_breadcrumbs_trail’, 10); 4 – Boş araba / * * Boş WooCommerce Cart * / Function my_empty_cart () {global $ wooocommerce; $ wooocommerce-> cart-> boş_cart ();
} Add_action (‘init’, ‘my_empty_cart’); 5 – ziyaret edildiğinde sepete otomatik olarak ürün ekleyin / * * Ziyarette sepete öğeler ekleyin * / işlev add_product_to_cart () {if (! Is_admin ()) {global $ wooocommerce; $ ürün_id = 64; $ Found = false; // Ürün halihazırda sepette olup olmadığını ($ wooocommerce-> cart-> get_cart ())> 0) {foreach ($ wooocommerce-> cart-> get_cart () olarak $ cart_item_key => $ değerler) {$ _product olarak kontrol edin = $ değerler [‘veri’]; if ($ _product-> id == $ ürün_id) $ Found = true; } // Ürün bulunamazsa, (! $ Bulun) $ wooocommerce-> cart-> add_to_cart ($ ürün_id); } else {// Sepette ürün yoksa, $ wooocommerce-> cart-> add_to_cart ($ ürün_id); }}} add_action (‘init’, ‘add_product_to_cart’); 6 – Özel bir para birimi / sembolü ekle add_filter (‘wooocommerce_currences’, ‘add_my_currency’); Function add_my_currency ($ currices) {$ currices [‘abc’] = __ (‘para birimi adı’, ‘wooocommerce’); Dönüş $ para birimleri; } add_filter (‘wooocommerce_currency_symbol’, ‘add_my_currency_symbol’, 10, 2); Function add_my_currency_symbol ($ currency_symbol, $ currency) {switch ($ para birimi) {case ‘abc’: $ currency_symbol = ‘$’; kırmak; } return $ currency_symbol; } 7 – Metin düğmesini değiştir Tramvaya ekle / ** * Tek ürün sayfalarındaki sepet metnine ekle değiştirin * / işlev woo_custom_cart_button_text () __ (‘Düğme metnim’, ‘wooocommerce’); } add_filter (‘single_add_to_cart_text’, ‘woo_custom_cart_button_text’); / ** * Ürün arşivlerinde sepet metnine ekle ekle */ function woo_archive_custom_cart_button_text () {return __ (‘
Düğme metnim ‘,’ wooocommerce ‘);} add_filter (‘add_to_cart_text’, ‘woo_archive_custom_cart_button_text’);8 – Aboneliği Yeniden Yönlendirme Ödeme sayfasına ekleyin / ** * Ölçüm, ödeme sayfasına sepete ekle * * @param String $ url * / function custom_add_to_cart_redirect ($ url) {$ ürün_id = (int) $ _Request [” eklenti ‘];if (class_exists (‘wc_subscriptions_product’)))) {if (wc_subscriptions_product :: is_subscription ($ ürün_id)) {return get_permalink (‘wooocommerce_checkout_page_id’);} else döndür $ url;} else döndür $ url;} add_filter (‘add_to_cart_redirect’, ‘Custom_add_to_cart_redirect’);Bu görüntü bir abonelik eklentisi gerektirir.
9 – Sepete eklendikten sonra ödeme sayfasına yönlendirin / ** * Aboneliğe Çıkarma Sayfasına Ekle Ekle sayfasına ekle * * @param none * / function_to_cart_checkout_redirect () {wp_safe_redirect (get_option (” ölmek (); } Add_action (‘wooocommerce_add_to_cart’, ‘add_to_cart_checkout_redirect’, 11); 10-CC Tüm e-posta /** * WooCommerce Ekstra Özellik * —————————- * * Tüm Woocommerce’e başka bir e-posta alıcısı ekleyin E -postalar * */ işlev woo_cc_all_emails () {return ‘bcc: [e -posta korumalı] ‘. ”
“;} add_filter (‘woocommerce_email_headers’, ‘woo_cc_all_emails’); 11-send kullanılmış bir kupon ile yeni bir sipariş tamamlandığında bir e-posta / * woocommerce ekstra özellik * ——— ————————– ———– * * Kupon ile her siparişte bir e-posta gönderin (S tamam * e-posta ödeme işlemi sırasında kullanılan kupon (lar) içerir */ işlev woo_email_order_coupons ($ sipariş_id) {$ sipariş) = yeni wc_order ($ sipariş_id); if ($ sipariş-> get_ussed_coupons ()) {$ to = ‘[e -posta korumalı] ; $ suic =’ yeni sipariş tamamlandı ‘; $ başlıklar =’ from: benim adım ‘. ”
“; $ Message = ‘Yeni bir sipariş tamamlandı.
‘; $ mesaj. = ‘Sipariş kimliği:’. $ sipariş_id. ‘
‘; $ Message. = ‘Kullanılan kuponlar:
‘; foreach ($ sipariş-> get_used_coupons () $ kupon olarak) {$ mesaj. = $ kupon. ‘
‘; } @wp_mail ($ ila, $ subion, $ mesaj, $ başlıklar); }} Add_action (‘wooocommerce_thankyou’, ‘woo_email_order_coupons’);
12 Değişiklik İlgili Ürün Numarası /** * WooCommerce Ekstra Özellik * —————————- * * İlgili ürünlerin sayısını değiştirin Ürün Sayfası * ‘Posts_per_page’ */ işlev için kendi değerinizi ayarlayın woo_related_products_limit () {global $ ürün; $ args = Array (‘Post_type’ => ‘ürün’, ‘No_found_row’ => 1, ‘Post_per_page’ => 6, ‘IGNE_STICKY_POSTS’ => 1, ‘sipariş by’ => $ siparişby, ‘Post_,’ Post__Not_in ‘= = > dizi ($ ürün-> id)); Dönüş $ args; } add_filter (‘wooocommerce_related_products_args’, ‘woo_related_products_limit’); 13-Mağaza sayfasındaki belirli kategorilerden ürünler ekspllude / ** * Mağazalardan ürünleri kategorisinden kaldırın * / function woo_custom_pre_get_posts_query ($ q) {if (! $ Q-> is_main_query ()) dönüşü; eğer (! $ q-> is_post_type_archive ()) döndürürse; if (! Is_admin () && is_shop ()) {$ q-> set (‘Tax_query’, dizi (dizi (‘taksonomi’ => ‘ürün_cat’, ‘tarla’ => ‘slug’, ‘terim’ => dizi (‘ayakkabı’), // ‘Operator’ => ‘not in’))))))))))); } remove_ace (‘pre_get_posts’, ‘Custom_prre_get_posts_query’); } Add_action (‘pre_get_posts’, ‘woo_custom_pre_get_posts_query’); 14 Mağaza Sütun Numarası /** * WooCommerce Ekstra Özellik * ———————— * * * Ürün Sütunları Numarasını Değiştirin Mağaza sayfaları */ işlev woo_product_columns_fronend () {global $ wooocommerce; // varsayılan değer kategoriler için de kullanılır ve sub_categories $ sütunlar = 4;