Jump to content

aveeva

Members
  • Posts

    89
  • Joined

  • Last visited

Everything posted by aveeva

  1. @Barand Yes, actually i am getting error, i don't want keep you disturb, that's what post to other forum, code: $output .= ' <div class="col-sm-3 col-lg-4 col-md-3"> <div style="border:1px solid #ccc; border-radius:5px; padding:10px; margin-bottom:16px; height:300px;"> <audio controls controlsList="nodownload" style="padding: 10px 10px 10px 10px;margin-left: -21px;"> <source src="audio_sample/'. $row['voice_audio_file'] .'" alt="" class="img-responsive"> </audio> <p align="center"><strong> '. $row['voice_name'] .'</strong></p> <p style="font-size: 12px;"> Voice Sku : '. $row['voice_sku'].' <br /> voice Name : '. $row['voice_name'].' <br /> Gender : '. $row['voice_gender'].' <br /> Genres : '. $row['voice_genres'].' <br /> Voice Modulation : '. $row['voice_voice_modulation'].' <br /> Languages : '. $row['voice_languages'].' <br /> Jingle Moods : '. $row['voice_jingle_moods'].' <br /> Ivr : '. $row['voice_ivr'].' <br /> </p> <button type="button" class="btn btn-primary" style="padding: 5px 83px 5px 83px;" data-voice-sku="'.$row["voice_sku"].'" data-voice-name="'.$row["voice_name"].'">Add to Playlist</button> </div> </div> '; } } else { $output = '<h3>No Data Found</h3>'; } echo $output; } ?> <script type="text/javascript"> $().ready( function() { $(".btn").click( function() { var voice_sku = $(this).data("voice_sku"); var voice_name = $(this).data("voice_name"); $.post( "my_cart.php", { "voice_sku" : voice_sku, "voice_name" : voice_name}, function(resp) { var list = "<tr><td><b>ID</b></td><td><b>Title</b></td></tr>\n"; $.each(resp, function(k, v) { list = list + "<tr><td>" + k + "</td><td>" + v + "</td></tr>\n" }) $("#playlist").html(list) }, "JSON" ); }); }); </script> my_cart.php: <?php session_start(); if ($_SERVER['REQUEST_METHOD']=='POST') { $voice_sku = $_POST['voice_sku'] ?? 0; $voice_name = $_POST['voice_name'] ?? ''; if ($voice_sku && $voice_name) { $_SESSION['playlist'][$voice_sku] = $voice_name; exit(json_encode($_SESSION['playlist'])) ; } } exit("ERROR") ; ?> screenshot :
  2. @ginerjm I am learning stage in PHP, really thanks to your steps, Now working good, As i said already this is for add to cart, how to each data to my_cart.php, my page : How to save more than one value?
  3. I am under developing PHP add to cart without DB, so that i am using SESSION, actually get data from fetch_data.php data to my_cart.php using the POST method, successfully retun the values, After receiving the post data how can i convert to display like a table. workout: fetch_data.php return values. https://snag.gy/IASCMZ.jpg & values received https://snag.gy/ojWxHe.jpg Here is my my_cart.php : // FYI -> Here i am using only two fields : voice_sku & voice_name <table width="100%" cellpadding="6" cellspacing="0"> <thead> <tr> <th>Voice Sku</th> <th>Voice Name</th> <th>Remove</th> </tr> </thead> <tbody> <?php session_start(); $voice_sku = ''; $voice_name = ''; if(isset($_POST['voice_sku'])&& isset($_POST['voice_name'])) { // print_r($_POST); // die(); $voice_sku = $_POST['voice_sku']; $voice_name = $_POST['voice_name']; $_SESSION['voice_sku'] = $voice_sku; $_SESSION['voice_name'] = $voice_name; } var_dump($_SESSION); ?> <tr> <td colspan="5"> <span style="float:right;text-align: right;"> <!-- --> </span> </td> </tr> <tr> <td colspan="5"> <a href="index.php" class="button">Add More Items</a> <button type="submit">Update</button> </td> </tr> </tbody> </table>
  4. String: NodeJs is one of the best technology From above, how to print technology which largest even number. How to print the largest even number?
  5. I am working PHP project on localhost using wamp, for debug process we using error_log() function, every time error_log() stored details of the error in wamp/logs, how can I view my error in the same project folder like wamp/www/goodgoal/ eg: wamp/www/goodgoal/logs/error_log.log Note : Pls recommend PHP Quick Debug Tricks
  6. Without store database is possible do with session, like add to playlist then checkout eg: https://www.phpzag.com/build-shopping-cart-with-ajax-php-and-mysql/
  7. @Barand Here is my inspect element, and my my_cart.php <?PHP ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); // Get details from fetch_data.php $voice_id = ''; $voice_name = ''; if(isset($_POST['voice_id']) && isset($_POST['voice_name'])) { $voice_id = $_POST['voice_id']; $voice_name = $_POST['voice_name']; } echo "$voice_id & $voice_name"; ?> How to make display like:
  8. @Barand Here is my my_cart.php, <?PHP ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); // Get details from fetch_data.php $voice_id = ''; $voice_name = ''; if(isset($_POST['voice_id']) && isset($_POST['voice_name'])) { $voice_id = $_POST['voice_id']; $voice_name = $_POST['voice_name']; } echo "$voice_id & $voice_name"; ?> My output : if i click add to playlist button the values not reflect on my_cart.php. I just want if i click add to playlist button the each value display on my my_cart.php page like, 1 1_tamil_voice.mp3 2 3_tamil_voice.mp3 3 3_tamil_voice.mp3 Like add-to-cart function.
  9. I really appreciate with code help, Actually, i did mistake in my code : Now i correct, <script> $('.btn').on('click',function() { var voice_id = $("#voice_id"); var voice_name = $("#voice_name"); $.ajax({ type : "POST", url : "my_cart.php", datatype : "text", // data : {voice_id: voice_id, voice_name: voice_name }, data: "voice_id="+voice_id+"&voice_name="+voice_name, success: function(data) { console.log(data); // console.log('success',data); } }); }); </script> finally ,my output sorry to confusing...
  10. Not shared with my_cart.php file, my my_cart.php file is, <?PHP // Get details from fetch_data.php if(isset($_POST['voice_id']) && isset($_POST['voice_name'])) { $voice_id = $_POST['voice_id']; $voice_name = $_POST['voice_name']; } echo "$voice_id & $voice_name"; ?>
  11. Here is my PHP, i want to share voice_id and voice_name to another php file using ajax, <?php //fetch_data.php include('database_connection.php'); if(isset($_POST["action"])) { $query = " SELECT * FROM voice_bank_data WHERE voice_status = '1' "; // if(isset($_POST["minimum_price"], $_POST["maximum_price"]) && !empty($_POST["minimum_price"]) && !empty($_POST["maximum_price"])) // { // $query .= " // AND product_price BETWEEN '".$_POST["minimum_price"]."' AND '".$_POST["maximum_price"]."' // "; // } // Gender if(isset($_POST["gender"])) { $gender_filter = implode("','", $_POST["gender"]); $query .= " AND voice_gender IN('".$gender_filter."') "; } // Genres if(isset($_POST["genres"])) { $genres_filter = implode("','", $_POST["genres"]); $query .= " AND voice_genres IN('".$genres_filter."') "; } // Voice Modulation if(isset($_POST["voice_modulation"])) { $voice_modulation_filter = implode("','", $_POST["voice_modulation"]); $query .= " AND voice_voice_modulation IN('".$voice_modulation_filter."') "; } // Languages if(isset($_POST["languages"])) { $languages_filter = implode("','", $_POST["languages"]); $query .= " AND voice_languages IN('".$languages_filter."') "; } // Jingle Moods if(isset($_POST["jingle_moods"])) { $jingle_moods_filter = implode("','", $_POST["jingle_moods"]); $query .= " AND voice_jingle_moods IN('".$jingle_moods_filter."') "; } // IVR if(isset($_POST["ivr"])) { $ivr_filter = implode("','", $_POST["ivr"]); $query .= " AND voice_ivr IN('".$ivr_filter."') "; } $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); $total_row = $statement->rowCount(); $output = ''; if($total_row > 0) { foreach($result as $row) { $output .= ' <div class="col-sm-3 col-lg-4 col-md-3"> <div style="border:1px solid #ccc; border-radius:5px; padding:10px; margin-bottom:16px; height:300px;"> <audio controls controlsList="nodownload" style="padding: 10px 10px 10px 10px;margin-left: -21px;"> <source src="audio_sample/'. $row['voice_audio_file'] .'" alt="" class="img-responsive"> </audio> <p align="center"><strong> '. $row['voice_name'] .'</strong></p> <p style="font-size: 12px;"> Id : '. $row['voice_id'].' <br /> Name : '. $row['voice_name'].' <br /> Gender : '. $row['voice_gender'].' <br /> Genres : '. $row['voice_genres'].' <br /> Voice Modulation : '. $row['voice_voice_modulation'].' <br /> Languages : '. $row['voice_languages'].' <br /> Jingle Moods : '. $row['voice_jingle_moods'].' <br /> Ivr : '. $row['voice_ivr'].' <br /> </p> <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;">Add to PlayList </button> </div> </div> '; } } else { $output = '<h3>No Data Found</h3>'; } echo $output; } ?> <script> $('.button').on('click',function() { var voice_id = $("#voice_id").val(); var voice_name = $("#voice_name").val(); $.ajax({ type : "POST", url : "my_cart.php", datatype : "text", data : {voice_id: voice_id, voice_name: voice_name }, success: function(data) { console.log(data); // console.log('success',data); } }); }); </script> Not shared the details,
  12. After correcting the syntax error, my logic not working but observer triggered. <?php ini_set('display_errors', '1'); Mage::log('fine dude', null, 'logfile.log'); class Brst_Test_Model_Observer { //Put any event as per your requirement public function logCartAdd() { Mage::log('good dude', null, 'logfile.log'); // try{ $product = Mage::getModel('catalog/product') ->load(Mage::app()->getRequest()->getParam('product', 0)); $cart_qty = (int) Mage::getModel('checkout/cart')->getQuote()->getItemsQty(); if ($product->getId()==31588 && $cart_qty > 0) { Mage::throwException("You can not add This special Product, empty cart before add it"); } // $quote = Mage::getSingleton('checkout/session')->getQuote(); // if ($quote->hasProductId(2)) //{ // Mage::getSingleton("core/session")->addError("Cart has Special Product you can not add another"); // return; // } $quote = Mage::getModel('checkout/cart')->getQuote(); foreach ($quote->getAllItems() as $item) { $productId = $item->getProductId(); if($productId==31588){ Mage::throwException("Cart has Special Product you can not add another"); } } // }catch(Exception $e) // { // // Mage::log($e, null, 'logfile.log'); // echo $e->getMessage(); // } } } ?> finally not working but observer triggered, still other products added to cart if restricted products available in cart. How to do my module a better way? FYI: logfile.log 2019-06-28T06:05:00+00:00 DEBUG (7): fine dude 2019-06-28T06:05:00+00:00 DEBUG (7): good dude
  13. @Barand if ($product->getId()==31588 && $cart_qty > 0) { Mage::throwException("You can not add This special Product, empty cart before add it"); } Is it now okay?
  14. I just try with try cache error handling : <?php ini_set('display_errors', '1'); Mage::log('fine dude', null, 'logfile.log'); class Brst_Test_Model_Observer { //Put any event as per your requirement public function logCartAdd() { Mage::log('good dude', null, 'logfile.log'); try{ $product = Mage::getModel('catalog/product') ->load(Mage::app()->getRequest()->getParam('product', 0)); $cart_qty = (int) Mage::getModel('checkout/cart')->getQuote()->getItemsQty(); if ($product->getId()==31588 && $cart_qty > 0) { Mage::throwException("You can not add This special Product, empty cart before add it"); } // $quote = Mage::getSingleton('checkout/session')->getQuote(); // if ($quote->hasProductId(2)) //{ // Mage::getSingleton("core/session")->addError("Cart has Special Product you can not add another"); // return; // } $quote = Mage::getModel('checkout/cart')->getQuote(); foreach ($quote->getAllItems() as $item) { $productId = $item->getProductId(); if($productId==31588){ Mage::throwException("Cart has Special Product you can not add another"); } } }catch(Exception $e) { // Mage::log($e, null, 'logfile.log'); echo $e->getMessage(); } } } ?> and my logfile.log file 2019-06-28T05:50:11+00:00 DEBUG (7) : fine dude 2019-06-28T05:50:11+00:00 DEBUG (7) : good dude If i am right?
  15. How to setup error logging with proper permission?
  16. If i run below code in observer.php there is no warning: <?php ini_set('display_errors', '1'); $cart_qty = 123; if (cart_qty > 0) { exit("You can not add This special Product, empty cart before add it"); } exit('done');
  17. @NotionCommotion I am new to PHP, i try module like no other products eligible to add add-to-cart if restricted product available in the cart, so i got the script from stackoverflow,the script based on magento observer. I am not able to find the error, can i get help to find the error?
  18. @NotionCommotion If i try with try and cache debug, no error, <?php ini_set('display_errors', '1'); Mage::log('Hy observer called', null, 'add_to_cart_logfile.log'); class Brst_Test_Model_Observer { //Put any event as per your requirement public function logCartAdd() { try{ Mage::log('test', null, 'add_to_cart_logfile.log'); $product = Mage::getModel('catalog/product') ->load(Mage::app()->getRequest()->getParam('product', 0)); $cart_qty = (int) Mage::getModel('checkout/cart')->getQuote()->getItemsQty(); if ($product->getId()==31588 && cart_qty > 0) { Mage::throwException("You can not add This special Product, empty cart before add it"); } // $quote = Mage::getSingleton('checkout/session')->getQuote(); // if ($quote->hasProductId(2)) //{ // Mage::getSingleton("core/session")->addError("Cart has Special Product you can not add another"); // return; // } $quote = Mage::getModel('checkout/cart')->getQuote(); foreach ($quote->getAllItems() as $item) { $productId = $item->getProductId(); if($productId==31588){ Mage::throwException("Cart has Special Product you can not add another"); } } }catch(Exception $e) { Mage::log($e, null, 'add_to_cart_logfile.log'); } } } ?>
  19. @NotionCommotion No there is no error, how to find the error?
  20. Created module like No other products add to cart if restricted product available in cart and vice versa. My Module : app/etc/modules/Brst_Test.xml <?xml version="1.0"?> <config> <modules> <Brst_Test> <active>true</active> <codePool>community</codePool> </Brst_Test> </modules> </config> This is my observer file app/code/community/Brst/Test/Model/Observer.php <?php ini_set('display_errors', '1'); // Mage::log('Hy observer called', null, 'logfile.log'); class Brst_Test_Model_Observer { //Put any event as per your requirement public function logCartAdd() { $product = Mage::getModel('catalog/product') ->load(Mage::app()->getRequest()->getParam('product', 0)); $cart_qty = (int) Mage::getModel('checkout/cart')->getQuote()->getItemsQty(); if ($product->getId()==31588 && cart_qty > 0) { Mage::throwException("You can not add This special Product, empty cart before add it"); } // $quote = Mage::getSingleton('checkout/session')->getQuote(); // if ($quote->hasProductId(2)) //{ // Mage::getSingleton("core/session")->addError("Cart has Special Product you can not add another"); // return; // } $quote = Mage::getModel('checkout/cart')->getQuote(); foreach ($quote->getAllItems() as $item) { $productId = $item->getProductId(); if($productId==31588){ Mage::throwException("Cart has Special Product you can not add another"); } } } } ?> app/code/community/Brst/Test/etc/config.xml <?xml version="1.0"?> <config> <modules> <Brst_Test> <version>0.1.0</version> </Brst_Test> </modules> <global> <models> <brst_test> <class>Brst_Test_Model</class> </brst_test> </models> </global> <frontend> <events> <controller_action_predispatch_checkout_cart_add> <observers> <brst_test_log_cart_add> <class>brst_test/observer</class> <method>logCartAdd</method> </brst_test_log_cart_add> </observers> </controller_action_predispatch_checkout_cart_add> </events> </frontend> </config> Not working, how to solve the error?
  21. I have one restricted product, here how to do selected single product should be purchased alone? No other products are eligible to add add-to-cart if this product available in the add-to-cart, same if other products available in add-to-cart this product not eligible to add add-to-cart. How to achieve this in Magento?
  22. I am following the below module,https://www.webslesson.info/2018/04/...-ajax-php.htmlHow can i use without quantity [Product Name, Price, total, Action] i tried lot fail again and again. I am learning stage in PHP, any help pls welcome.
  23. Forgot Your Password Not working at the customer end, how to solve this error? Reset Password Email not sending to the customer mail account.
  24. My index.php, $output .= ' <div class="col-sm-3 col-lg-4 col-md-3"> <div style="border:1px solid #ccc; border-radius:5px; padding:10px; margin-bottom:16px; height:300px;"> <audio controls controlsList="nodownload" style="padding: 10px 10px 10px 10px;margin-left: -21px;"> <source src="audio_sample/'. $row['voice_audio_file'] .'" alt="" class="img-responsive"> </audio> <p align="center"><strong> '. $row['voice_name'] .'</strong></p> <p style="font-size: 12px;"> Id : '. $row['voice_id'].' <br /> Name : '. $row['voice_name'].' <br /> Gender : '. $row['voice_gender'].' <br /> Genres : '. $row['voice_genres'].' <br /> Voice Modulation : '. $row['voice_voice_modulation'].' <br /> Languages : '. $row['voice_languages'].' <br /> Jingle Moods : '. $row['voice_jingle_moods'].' <br /> Ivr : '. $row['voice_ivr'].' <br /> </p> <button type="button" class="btn btn-primary" type="submit" onclick="addCart('. "'".$row["voice_id"]."'".','."'". $row["voice_name"]."'".');" style="padding: 5px 83px 5px 83px;">Add to PlayList </button> same page ajax : <script> function addCart(voice_id, voice_name) { $.ajax({ type: 'POST', url: 'cart.php', data: { voice_id : voice_id, voice_name : voice_name }, dataType: 'text', success: function(data) { // alert(data); } }); } $(document).ready(function(){ }); </script> and get.php <?php $voice_id =" "; $voice_name=" "; if(isset($_POST['voice_id']) && isset($_POST['voice_name'])) { $voice_id = $_POST['voice_id']; $voice_name = $_POST['voice_name']; } echo "$voice_id, . "&". , $voice_name"; ?> if click button, the value send but the get.php not properly get the value and display on the php page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.