Support » Plugin: Woocommerce Ajax add to cart for variable products » Woocommerce Deposits Breaks Ajax

  • Hi. If this plugin is used with Woocommerce Deposits the deposit amount is ignored and instead the ajax plugin sends the full product value. Is there a way to edit the code to grab the value that is sent from WooCommerce deposits so that the correct price is recorded?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author rcreators


    Hello D1ch0t,

    I recommend you to rename plugin first, so you don;t run into issue when i update plugin.

    Then there are 2 main things you need to add in 2 files. 1 js file and 1 php file.

    In plugin root directory, you will get js folder, in which you will find jquery which gets data from html and sends to ajax function.

    Edit js file and go to line no 75, add a code to get value of deposit field and store into variable. will be something like this.

    var deposit = $variation_form.find( 'input[name=deposit]' ).val();

    Below that you need to send this value into ajax data. So data will be update to something like below.

    var data = {
    				action: 'woocommerce_add_to_cart_variable_rc',
    				product_id: product_id,
    				quantity: quantity,
    				variation_id: var_id,
    				variation: item,
    				deposit: deposit 

    In above the first deposit is post name while second deposit is variable name which we get from first code above.

    You are done with Js now its time to update PHP file.

    Open the php file from main directory. And go to line 117 which is woocommerce_add_to_cart_variable_rc_callback function. Here you need to get the post deposit data and send to further process.

    To get the data, you just simply need to add below line at 124

    $deposit = $_POST['deposit'];

    Now to process it and sending further to cart as price, i am not sure. you need to check deposit plugin for same how its overriding default price and sending deposit one and add that code accordingly in this function.

    Let me know if you still have some confusion.

    Hi, thanks for the detailed explanation however it still doesn’t work. I followed your instructions exactly.

    Here is the HTML that WC Deposits places into the document:

    <div class="wc-deposits-wrapper wc-deposits-optional">
     <ul class="wc-deposits-option">
      	<input type="radio" name="wc_deposit_option" value="yes" id="wc-option-pay-deposit" checked="checked">
    	<label for="wc-option-pay-deposit">Pay Deposit</label>
    	<input type="radio" name="wc_deposit_option" value="no" id="wc-option-pay-full">
    	<label for="wc-option-pay-full">Pay in Full</label>
    <div class="wc-deposits-payment-description" style="display: block;">Pay a deposit of <span class="wc-deposits-amount"><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>10.00</span></span> per item</div>

    Any thoughts would be appreciated.

    • This reply was modified 3 years, 1 month ago by d1ch0t. Reason: code edit
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Woocommerce Deposits Breaks Ajax’ is closed to new replies.