Merhaba arkadaşlar, wordpress üzerinden bir ürün tanıtım sitesi kurmaya çalışıyorum, site üzerinden satış yapılmayacak o yüzden satın al butonlarına tıklandığında instagram sayfasına atmasını istiyorum, wp üzerinden butona link verilmiyor otomatik olarak ?add-to-card=79 isimli linke yönlendiriyor, sanırsam butonun kodlarını buldum ama php bilgim olmadığı için nasıl yapacağımı bilmiyorum yardımcı olabilir misiniz?
// add to cart button
function woocommerce_template_loop_add_to_cart( $args = array() ) {
global $product;
if ( $product ) {
$defaults = array(
'quantity' => 1,
'class' => implode(
' ',
array_filter(
array(
'cart-button icon-btn',
'product_type_' . $product->get_type(),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
$product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '',
)
)
),
'attributes' => array(
'data-product_id' => $product->get_id(),
'data-product_sku' => $product->get_sku(),
'aria-label' => $product->add_to_cart_description(),
'rel' => 'nofollow',
),
);
$args = wp_parse_args( $args, $defaults );
if ( isset( $args['attributes']['aria-label'] ) ) {
$args['attributes']['aria-label'] = wp_strip_all_tags( $args['attributes']['aria-label'] );
}
}
echo sprintf( '<a href="%s" data-quantity="%s" class="add-cart-btn %s" %s>%s</a>',
esc_url( $product->add_to_cart_url() ),
esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
esc_attr( isset( $args['class'] ) ? $args['class'] : 'cart-button icon-btn' ),
isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '','<i class="flaticon-shopping-cart-1"></i>'
);
}
Wordpress PHP yardımı.
5
●196
- 08-08-2023, 14:22:57
function custom_woocommerce_loop_add_to_cart_link( $html, $product ) { $instagram_link = "https://www.instagram.com/your_username/"; // Instagram hesabınız $button_text = __("Instagram'da Görüntüle", "domain"); // Butonun üzerindeki yazı return '<a href="' . $instagram_link . '" class="button" target="_blank">' . $button_text . '</a>'; } add_filter( 'woocommerce_loop_add_to_cart_link', 'custom_woocommerce_loop_add_to_cart_link', 10, 2 );functions.php dosyasına bu kodu ekleyin. - 08-08-2023, 14:59:50Üyeliği durduruldugözünü sevdiğimin gbt3.5 u
Anladım. Bu kod parçasını, ödeme kısmına geçmek yerine Instagram sayfanıza yönlendirebilmek için aşağıdaki gibi güncelleyebilirsiniz:
```php
$args = array();
global $product;
if ( $product ) {
$defaults = array(
'quantity' => 1,
'class' => implode(
' ',
array_filter(
array(
'cart-button icon-btn',
'product_type_' . $product->get_type(),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
$product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '',
)
)
),
'attributes' => array(
'data-product_id' => $product->get_id(),
'data-product_sku' => $product->get_sku(),
'aria-label' => $product->add_to_cart_description(),
'rel' => 'nofollow',
'href' => 'https://www.instagram.com/TEKENDAG/',
),
);
$args = wp_parse_args( $args, $defaults );
if ( isset( $args['attributes']['aria-label'] ) ) {
$args['attributes']['aria-label'] = wp_strip_all_tags( $args['attributes']['aria-label'] );
}
}
echo sprintf( '<a %s data-quantity="%s" class="%s" %s>%s</a>',
isset($args['attributes']) ? wc_implode_html_attributes( $args['attributes'] ) : '',
esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
esc_attr( isset( $args['class'] ) ? $args['class'] : 'cart-button icon-btn' ),
isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
'<i class="flaticon-shopping-cart-1"></i>'
);
```
Yukarıdaki güncelleme, `attributes` dizisine `href` özelliğini ekleyerek bağlantıyı Instagram sayfanıza yönlendirmek için kullanabilirsiniz. Lütfen "https://www.instagram.com/TEKENDAG/" bölümünü kendi Instagram sayfa URL'nizle değiştirmeyi unutmayın. - 08-08-2023, 15:25:08maalesef hocam daha önce denedim fakat anasayfa da bulunan ürünlerde işe yaramıyor ürün detayına girdiğinde bulunan satın al butonuna tanımlama yapılabiliyor bu şekilde sadece.Hurtech adlı üyeden alıntı: mesajı görüntüle