Guest User

Untitled

a guest
Apr 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. jQuery('.cart button').on('click', function () {
  2. var price = jQuery('.price').text();
  3. var priceValue = parseInt(price.substring(0, price.length - 1));
  4. var cart = jQuery('#cart');
  5. var cartValue = parseInt(cart.text().substring(0, cart.text().length - 1));
  6. cart.text(cartValue + priceValue + '$');
  7.  
  8. jQuery.getJSON("http://jsonip.com/?callback=?", function (data) {
  9. var ip = data.ip.toString();
  10.  
  11. jQuery.ajax({
  12. type: "POST",
  13. url: "../myupdate.php",
  14. data: ["ip="+ip, "cart="+jQuery('#cart').text()]
  15. }).done(function () {
  16. console.log('done');
  17. }).error(function () {
  18. console.log('error');
  19. });
  20.  
  21. });
  22.  
  23. <?php
  24. $ip = $_POST[ip];
  25. $cart = $_POST[cart];
  26. db_insert('abweb')
  27. ->fields(array('ip' => $ip, 'product' => 'some product', 'price' => $cart))
  28. ->execute();
  29.  
  30. function mymodule_commerce_cart_product_add($order, $product, $quantity, $line_item) {
  31.  
  32. $commerce_line_item = commerce_line_item_load($line_item->line_item_id);
  33.  
  34. $field_main = $product->field_main['und']['0']['value'];
  35.  
  36. $line_item->field_update[LANGUAGE_NONE][0]['value'] = $field_main;
  37.  
  38. commerce_line_item_save($line_item);
  39. }
Add Comment
Please, Sign In to add comment