WooCommerce İçin İşinizi Kolaylaştıracak Kodlar

  • Anasayfa
  • WooCommerce İçin İşinizi Kolaylaştıracak Kodlar

Woocommerce alt yapılı e-ticaret siteniz için işinizi kolaylaştıracak birkaç kod paylaşacağım bu kodlar temanızın functions.php dosyasına eklemeniz yeterli.

İndirim Yazısını Değiştirme

add_filter('woocommerce_sale_flash', 'my_custom_sale_flash', 10, 3);
function my_custom_sale_flash($text, $post, $_product)
{
    return 'Sizin Butonunuz';
}

Sepete Ekle Butonunu Kaldırmak

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

Kayıt Sayfasında Şifre Tekrarı


	

Mağaza Sayfasını Kapatmak

add_action('template_redirect','store_closed');
function store_closed(){
    if (!is_admin() && is_woocommerce()){
        wp_redirect('/magaza-kapaşi/'); // yönlenecek Link
        exit;
    }
}

Bir Kategori İçin Minimum Sipariş Miktarı Belirleme

add_action( 'woocommerce_check_cart_items', 'check_total' );
function check_total() {
    // Only run in the Cart or Checkout pages
    if( is_cart() || is_checkout() ) {

        global $woocommerce, $product;

        $total_quantity = 0;
        $display_notice = 1;
        $i = 0;
        //loop through all cart products
        foreach ( $woocommerce->cart->cart_contents as $product ) {

            // See if any product is from the cuvees category or not
            if ( has_term( 'category-1', 'product_cat', $product['product_id'] )) {
                $total_quantity += $product['quantity'];
            }

        }
        // Set up the acceptable totals and loop through them so we don't have an ugly if statement below.
        $acceptable_totals = array(1, 2, 3, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 72, 96, 120);

        foreach($acceptable_totals as $total_check) {
            if ( $total_check == $total_quantity ) { $display_notice = 0; } 
        }

        foreach ( $woocommerce->cart->cart_contents as $product ) {
            if ( has_term( 'category-1', 'product_cat', $product['product_id'] ) ) {
                if( $display_notice == 1 && $i == 0 ) {
                    // Display our error message
                    wc_add_notice( sprintf( 'This product can only be sold in following quantities 1 | 2 | 3 | 6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 | 60  | 72 | 96 | 120.

', $total_quantity), 'error' ); } $i++; } } }

Oturum Açmış Kullanıcılardan Fatura Adresini Kaldırmak

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
    if( is_user_logged_in() ){
        unset($fields['billing']);
		$fields['billing'] = array();
    }
    return $fields;
}

 

Şimdi Teklif Alın
Şimdi Teklif Alın

Projeniz ile ilgili veya web sitenizde takıldığınız alanlar ile ilgili şimdi teklif alın

WordPress ve WooCommerce Eklentilerim
Eklentilerim

WordPress ve WooCommerce İçin Hazırlamış olduğum Eklentiler

Şimdi Teklif Alın

Web tasarım, yazılım, mobil uygulama veya masa üstü program ihtiyaçlarınız için bana proje detaylarınızı gönderin. 24 saat içerisinde size detaylı teklif göndereyim.