Wordpress 删除WooCommerce的某些功能

Wordpress 删除WooCommerce的某些功能,wordpress,woocommerce,Wordpress,Woocommerce,我正在修改WordPress的主题,但找不到以下主题的解决方案: 一,。如何删除库中的WooCommerce产品图像?因为此图像是自动添加的,无法删除 图像: 二,。如何停用购物车页面,可能吗?我只对结账页面感兴趣。我一直在看一些代码,但它们不允许选择2个以上的产品 向所有发表评论的人致意,我希望这些问题能够在将来帮助更多的人。当产品添加到购物车时,重定向到签出 第二个问题答案: 如何停用购物车页面,可能吗?我只对结账页面感兴趣。我一直在看一些代码,但它们不允许选择2个以上的产品 第1步。 /

我正在修改WordPress的主题,但找不到以下主题的解决方案:

一,。如何删除库中的WooCommerce产品图像?因为此图像是自动添加的,无法删除

图像:

二,。如何停用购物车页面,可能吗?我只对结账页面感兴趣。我一直在看一些代码,但它们不允许选择2个以上的产品


向所有发表评论的人致意,我希望这些问题能够在将来帮助更多的人。

当产品添加到购物车时,重定向到签出


第二个问题答案: 如何停用购物车页面,可能吗?我只对结账页面感兴趣。我一直在看一些代码,但它们不允许选择2个以上的产品

第1步。

// Disable AJAX add to cart buttons
First of all, we have to do some small configurations in WooCommerce Settings – Uncheck the “Enable AJAX add to cart buttons on archives” checkbox.
// Change text on add to cart buttons
/*
 * Change button text on Product Archives
 */
add_filter( 'woocommerce_loop_add_to_cart_link', 'nik_add_to_cart_text_1' );

function nik_add_to_cart_text_1( $add_to_cart_html ) {
    return str_replace( 'Add to cart', 'Buy now', $add_to_cart_html );
}

/*
 * Change button text on product pages
 */
add_filter( 'woocommerce_product_single_add_to_cart_text', 'nik_add_to_cart_text_2' );

function nik_add_to_cart_text_2( $product ){
    return 'Buy now';
}
// Redirect to Checkout Page
add_filter( 'woocommerce_add_to_cart_redirect', 'nik_skip_cart_redirect_checkout' );

function nik_skip_cart_redirect_checkout( $url ) {
    return wc_get_checkout_url();
}
// Remove “The product has been added to your cart” message
add_filter( 'wc_add_to_cart_message_html', 'nik_remove_add_to_cart_message' );

function nik_remove_add_to_cart_message( $message ){
    return '';
}
第2步。

// Disable AJAX add to cart buttons
First of all, we have to do some small configurations in WooCommerce Settings – Uncheck the “Enable AJAX add to cart buttons on archives” checkbox.
// Change text on add to cart buttons
/*
 * Change button text on Product Archives
 */
add_filter( 'woocommerce_loop_add_to_cart_link', 'nik_add_to_cart_text_1' );

function nik_add_to_cart_text_1( $add_to_cart_html ) {
    return str_replace( 'Add to cart', 'Buy now', $add_to_cart_html );
}

/*
 * Change button text on product pages
 */
add_filter( 'woocommerce_product_single_add_to_cart_text', 'nik_add_to_cart_text_2' );

function nik_add_to_cart_text_2( $product ){
    return 'Buy now';
}
// Redirect to Checkout Page
add_filter( 'woocommerce_add_to_cart_redirect', 'nik_skip_cart_redirect_checkout' );

function nik_skip_cart_redirect_checkout( $url ) {
    return wc_get_checkout_url();
}
// Remove “The product has been added to your cart” message
add_filter( 'wc_add_to_cart_message_html', 'nik_remove_add_to_cart_message' );

function nik_remove_add_to_cart_message( $message ){
    return '';
}
我认为对于这种情况,str_replace()是最简单、最简单的解决方案,但是如果您不想使用它,可以用下面的代码替换代码的第一部分:

/*
 * Change button text on Product Archives
 */
add_filter( 'woocommerce_product_add_to_cart_text', 'nik_add_to_cart_text_1', 10, 2 );

function nik_add_to_cart_text_1( $text, $product ){
    return $product->is_purchasable() && $product->is_in_stock() ? 'Buy Now' : 'Read more';
}
第3步。

// Disable AJAX add to cart buttons
First of all, we have to do some small configurations in WooCommerce Settings – Uncheck the “Enable AJAX add to cart buttons on archives” checkbox.
// Change text on add to cart buttons
/*
 * Change button text on Product Archives
 */
add_filter( 'woocommerce_loop_add_to_cart_link', 'nik_add_to_cart_text_1' );

function nik_add_to_cart_text_1( $add_to_cart_html ) {
    return str_replace( 'Add to cart', 'Buy now', $add_to_cart_html );
}

/*
 * Change button text on product pages
 */
add_filter( 'woocommerce_product_single_add_to_cart_text', 'nik_add_to_cart_text_2' );

function nik_add_to_cart_text_2( $product ){
    return 'Buy now';
}
// Redirect to Checkout Page
add_filter( 'woocommerce_add_to_cart_redirect', 'nik_skip_cart_redirect_checkout' );

function nik_skip_cart_redirect_checkout( $url ) {
    return wc_get_checkout_url();
}
// Remove “The product has been added to your cart” message
add_filter( 'wc_add_to_cart_message_html', 'nik_remove_add_to_cart_message' );

function nik_remove_add_to_cart_message( $message ){
    return '';
}
第4步。

// Disable AJAX add to cart buttons
First of all, we have to do some small configurations in WooCommerce Settings – Uncheck the “Enable AJAX add to cart buttons on archives” checkbox.
// Change text on add to cart buttons
/*
 * Change button text on Product Archives
 */
add_filter( 'woocommerce_loop_add_to_cart_link', 'nik_add_to_cart_text_1' );

function nik_add_to_cart_text_1( $add_to_cart_html ) {
    return str_replace( 'Add to cart', 'Buy now', $add_to_cart_html );
}

/*
 * Change button text on product pages
 */
add_filter( 'woocommerce_product_single_add_to_cart_text', 'nik_add_to_cart_text_2' );

function nik_add_to_cart_text_2( $product ){
    return 'Buy now';
}
// Redirect to Checkout Page
add_filter( 'woocommerce_add_to_cart_redirect', 'nik_skip_cart_redirect_checkout' );

function nik_skip_cart_redirect_checkout( $url ) {
    return wc_get_checkout_url();
}
// Remove “The product has been added to your cart” message
add_filter( 'wc_add_to_cart_message_html', 'nik_remove_add_to_cart_message' );

function nik_remove_add_to_cart_message( $message ){
    return '';
}

感谢@Nikhil的评论,但现在我只能选择1合1产品。此外,如果我使某些组合再次出现购物车页面:(一个问题,我如何删除显示“产品”已删除的消息。撤消?隐藏消息。“产品”已删除,撤消?签出链接,希望这对您有所帮助。如果您要添加多个产品和签出,您必须启用ajax“添加到购物车”按钮。不要使用步骤3“重定向到签出页面”。您必须覆盖一些woocommerce文件。如何在“添加到购物车”按钮附近创建一个带有签出链接的按钮。选择“添加到购物车”时,在ajax完成后显示“无”添加到购物车按钮,并显示“阻止签出”按钮。这样您也可以实现直接签出。