logo
down
shadow

Woocommerce upsell with checkboxes


Woocommerce upsell with checkboxes

Content Index :

Woocommerce upsell with checkboxes
Tag : php , By : Frank Rotolo
Date : January 12 2021, 08:33 AM

wish of those help I'm having an issue with an new upsell section I've added for a wordpress/woocommerce website. , Your issue is caused by the following line:
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( the_ID() ), 'single-post-thumbnail' );?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); ?>
function the_ID() {
    echo get_the_ID();
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

WooCommerce add upsell product to the cart when product is added


Tag : wordpress , By : user104292
Date : March 29 2020, 07:55 AM
may help you . So finally, I found the solution to my question.
The problem was happening when the cart was loaded from the session via the function get_cart_from_session() from class-wc-cart.php.
/**
 * Add upsells as extra data for added product
 */
function add_upsells_to_cart( $cart_item_key ) {
    global $woocommerce;

    if ( empty( $_REQUEST['upsells'] ) || ! is_array( $_REQUEST['upsells'] ) )
        return;

    // Prevent loop
    $upsells = $_REQUEST['upsells'];
    unset( $_REQUEST['upsells'] );

    // Append each upsells to product in cart
    foreach( $upsells as $upsell_id ) {
        $upsell_id = absint( $upsell_id );

        // Add upsell into cart and set upsell_of as extra key with parent product item id
        $woocommerce->cart->add_to_cart( $upsell_id, 1, '', '', array( 'upsell_of' => $cart_item_key ) );
    }
}
add_action( 'woocommerce_add_to_cart', 'add_upsells_to_cart', 1, 6 );


/**
 * Inject upsell_of extra key cart item key when cart is loaded from session
 */
function get_cart_items_from_session( $item, $values, $key ) {
    if ( array_key_exists( 'upsell_of', $values ) )
        $item[ 'upsell_of' ] = $values['upsell_of'];

    return $item;
}
add_filter( 'woocommerce_get_cart_item_from_session', 'get_cart_items_from_session', 1, 3 );


/**
 * Remove associated upsells if product removed from cart
 */
function remove_upsells_from_cart( $cart_item_key ) {
    global $woocommerce;

    // Get cart
    $cart = $woocommerce->cart->get_cart();

    // For each item in cart, if item is upsell of deleted product, delete it
    foreach( $cart as $upsell_key => $upsell )
        if ( $upsell['upsell_of'] == $cart_item_key )
            unset( $woocommerce->cart->cart_contents[ $upsell_key ] );
}
add_action( 'woocommerce_before_cart_item_quantity_zero', 'remove_upsells_from_cart' );

Woocommerce add to cart event and upsell page


Tag : php , By : Chaz
Date : March 29 2020, 07:55 AM
hope this fix your issue It looks like it must be wrapped by a statement checking against page ID using get_the_ID() function to prevent "Add to cat" redirect on a custom page.

Woocommerce Product Attribute Values picked from Upsell and Cross Sell


Tag : php , By : Joshua Johnson
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I am displaying Upsell and Cross sell products on single product page. But unfortunately The Additional information tab which contains the attribute are picking from Upsell and Cross sell. , I fixed this problem by resetting the loop query.
<?php wp_reset_query(); ?>

Upsell on WooCommerce Thank You Page using Cross-selling products


Tag : development , By : cynix
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , The following get_post_meta doesn't necessarily returns a list of products:
get_post_meta( $item['product_id'], '_crosssell_ids', true )
foreach ( $items as $item ) {
$product_crosssell_ids = get_post_meta( $item['product_id'], '_crosssell_ids', true );

if (is_array($product_crosssell_ids) && !empty($product_crosssell_ids)){
$cross_ids = array_unique( array_merge( $product_crosssell_ids, $cross_ids )) ;
}

}

Using checkboxes for variations in WooCommerce to allow multiple choice


Tag : wordpress , By : Raghu
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Error while add data in database SQL Server 2016
  • Does PhpStorm allow to skip PHPDoc tags when type hints is declared?
  • html classes are changed to Attributes
  • Using json to import multidimensional data
  • passing data from the view to the controller, where the data comes from another controller
  • How to extract integer and decimal numbers in PHP string correctly?
  • Parsing Sub-Object from an XML Feed with objects
  • Getting error "Unknown column 'text' in 'field list'"
  • How to properly get onedrive access token via php and curl
  • How to add spell check to a php function
  • Is it posible to create css rules with php?
  • Pretty URL with $_GET method
  • Wordpress always load same page - index.php
  • Find value in array and return with new from different array
  • PHP multiple file upload with different keys
  • Can't modify times one a time without weird errors
  • Get size of scraped image with domcrawler (Goutte)
  • Laravel - Ordering a collection of models
  • PHP Fatal error: Uncaught Error: Call to a member function setFetchMode() on boolean
  • Strict Standards: Only variables should be passed by reference in /main_dir/sub_dir/backup.php
  • Uncaught Google_Exception: (update) unknown parameter: 'copyRequiresWriterPermission'
  • Laravel 5 form does not redirect with old input
  • How to get values greater than or equal to in Mysql database sql when its a value like 1:00 PM?
  • PHP datediff overday issue
  • Masking an auto incrementing primary key
  • How to grab a String BEFORE a certain word
  • ZF2 Routing Multiple Controllers based on route constraints
  • How to deregister/dequeue jquery.sticky.js in Elementor (Pro)?
  • How to fix errors counting words in text plain with PHP?
  • How to get View data in Laravel in custom helper or directive
  • Creating a new data entry into a database with eloquent and trying to access the variable in the url
  • How to test authentication using Laravel Dusk?
  • PHP parse_str not getting all $_GET variables
  • Variable issues in php class
  • Get orders between dates in Codeigniter
  • Eloquent Special Chars Issue
  • Keeping leading zeros column Mysql
  • Current level navigation in Wordpress
  • Add a custom text to WooCommerce cart items if the product has a specific shipping class
  • Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate
  • How do I add a new key value pair to an object in PHP?
  • Http post request to php with dart
  • How to add a route in with blade into parameters of a component
  • How can i get the source of a 777 - CHMOD php file?
  • Convert 2010-04-16 16:30:00 to "Tomorrow Afternoon"
  • How can I hide a $_GET variable to be more secured in PHP?
  • Login to Gmail Inbox using Curl?
  • Upload Excel or CSV file to MySQL with PHP
  • Outlook Marking Email as Junk Email
  • Upload an image using class.upload.php via AJAX, display image in form using jQuery
  • mysql_connect() causes page to not display (WAMP)
  • How to limit a users uploaded image size using PHP
  • What's the difference whether or not to run PHP in safe mode?
  • Logging in to a website cURL
  • Using php to create a password system with chinese characters
  • PHP is not called properly in IE using set interval function in Javascript
  • How to read pdf, ppt, xl, doc files content into a string in php/python
  • php script for currency conversion
  • In PHP... best way to turn string representation of a folder structure into nested array
  • PayPal for Indian Rupees (INR) any solution
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com