Jump to content

aveeva

Members
  • Content Count

    61
  • Joined

  • Last visited

Everything posted by aveeva

  1. How to self check what event i am using, my event : <checkout_cart_product_add_after> how to print, i tried : $event = $observer->getEvent()->getName(); Mage::log($event, null, 'logfile.log'); its not printing
  2. I am using extra fees extension, if customer chooses shipping method: Pick from the store how to remove Handling fees(extra fees extension). How to solve by using observer?
  3. config.xml <?xml version="1.0"?> <config> <modules> <Gta_KolupadiRestrict> <version>1.0.0</version> </Gta_KolupadiRestrict> </modules> <global> <models> <gta_kolupadirestrict> <class>Gta_KolupadiRestrict_Model</class> </gta_kolupadirestrict> </models> <events> <checkout_cart_product_add_after> <observers> <Gta_KolupadiRestrict_Model_Observer> <type>singleton</type> <class>Gta_KolupadiRestrict_Model_Observer</class> <method>cartevent</method> </Gta_KolupadiRestrict_Model_Observer> </observers> </checkout_cart_product_add_after> </events> </global> </config>
  4. @Barand @NotionCommotion Like same how can i get category_id, my observer : <?php class Gta_KolupadiRestrict_Model_Observer { public function cartevent(Varien_Event_Observer $observer) { // Load product $product = $observer->getProduct(); $prodID = $product->getId(); $_product = Mage::getModel('catalog/product')->load($prodID); // get category id $categoryIds = $_product->getCategoryIds(); // check cart $cart_qty = (int)Mage::getModel('checkout/cart')->getQuote()->getItemQty(); // check conditiion cart has other products if(in_array(681, $categoryIds) && $cart_qty > 0) { Mage::throwException("You can not add This special Product, empty cart before add it"); } // check if other products add to cart $quote = Mage::getModel('checkout/cart')->getQuote(); foreach ($quote->getAllItems() as $item) { $_product1 = $item->getProduct(); $categoryIds1 = $_product1->getCategoryIds(); if(in_array(681, $categoryIds1)) { Mage::throwException("If you want Kolu Padi, Purchase alone not mixed with other Products"); break; } } } } ?> condition : I just want to restrict some of the category of products to purchase with other category products, Workout : If customer click add to cart, using observer compare current add-to-cart product category id & already cart products category id, if the current product category id and cart products category id different display message like, You can not add This special Product, empty cart before add it and also vice versa if cart has restricted category of products, if customer try to add other products throw exception like If you want Kolu Padi, Purchase alone not mixed with other Products My error : a:5:{i:0;s:67:"If you want Kolu Padi, Purchase alone not mixed with other Products";i:1;s:1835:"#0 /home/abc/public_html/app/code/local/Gta/KolupadiRestrict/Model/Observer.php(21): Mage::throwException('If you want Kol...') #1 /home/abc/public_html/app/code/core/Mage/Core/Model/App.php(1358): Gta_KolupadiRestrict_Model_Observer->cartevent(Object(Varien_Event_Observer)) #2 /home/abc/public_html/app/code/core/Mage/Core/Model/App.php(1337): Mage_Core_Model_App->_callObserverMethod(Object(Gta_KolupadiRestrict_Model_Observer), 'cartevent', Object(Varien_Event_Observer)) #3 /home/abc/public_html/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('checkout_cart_p...', Array) #4 /home/abc/public_html/app/code/core/Mage/Checkout/Model/Cart.php(290): Mage::dispatchEvent('checkout_cart_p...', Array) #5 /home/abc/public_html/app/code/local/Cmsmart/AjaxCart/controllers/IndexController.php(315): Mage_Checkout_Model_Cart->addProduct('5071', Array) #6 /home/abc/public_html/app/code/local/Cmsmart/AjaxCart/controllers/IndexController.php(133): Cmsmart_AjaxCart_IndexController->tryaddAction(Object(Mage_Catalog_Model_Product), Array) #7 /home/abc/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Cmsmart_AjaxCart_IndexController->indexAction() #8 /home/abc/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index') #9 /home/abc/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #10 /home/abc/public_html/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch() #11 /home/abc/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array) #12 /home/abc/public_html/australia/index.php(93): Mage::run('australia', 'website') #13 {main}";s:3:"url";s:100:"/ajaxcart/index/index/?form_key=MtlJbvKkqPQKCLJR&product=5071&related_product=&qty=1&_=1565155804563";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:9:"australia";}
  5. Observer not triggered and log file not created. app/etc/modules/Gta_KolupadiRestrict.xml <?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Gta_KolupadiRestrict> <active>true</active> <codepool>local</codepool> </Gta_KolupadiRestrict> </modules> </config> app/code/local/Gta/KolupadiRestrict/etc/config.xml <?xml version="1.0"?> <config> <modules> <Gta_KolupadiRestrict> <version>1.0.0</version> </Gta_KolupadiRestrict> </modules> <global> <models> <gta_kolupadirestrict> <class>Gta_KolupadiRestrict_Model</class> </gta_kolupadirestrict> </models> </global> <frontend> <events> <checkout_cart_product_add_after> <observers> <Gta_KolupadiRestrict_Model_Observer> <type>singleton</type> <class>Gta_KolupadiRestrict_Model_Observer</class> <method>cartevent</method> </Gta_KolupadiRestrict_Model_Observer> </observers> </checkout_cart_product_add_after> </events> </frontend> </config> app/code/local/Gta/KolupadiRestrict/Model/Observer.php <?php // Mage::log('fine dude', null, 'logfile.log'); //create class class Gta_KolupadiRestrict_Model_Observer { //create function public function cartevent(Varien_Event_Observer $observer) { $event = $observer->getEvent(); Mage::log($event->getName(),null,'event.log'); } } ?>
  6. @Barand I just try with category instead of products, here i am facing some issue, could you pls help me, public function cartevent(Varien_Event_Observer $observer) { // $category_id = array(680, 894, 895) ; //category ids $category_products = Mage::getModel('catalog/category') ->addAttributeToFilter('category_id', array('in' => array('680','894','895'))) ->setWebsiteId(2); // load website id // check cart qty status $cart_qty = (int) Mage::getModel('checkout/cart')->getQuote()->getItemQty(); //logic if($category_products && $cart_qty > 0 ) { Mage::throwException("If you want Kolu Padi, Purchase alone not mixed with other Products"); } //check if cart have products $quote = Mage::getModel('checkout/cart')->getQuote(); foreach($quote->getAllItems() as $item) { $productId = $item->getCategoryId(); if($productId == $category_products) { Mage::throwException("Cart has Special Product you can not add another"); } } } Observer not trigger. could you pls help me
  7. help me with my workout : my_cart.php: <?php header('Content-Type: text/html; charset=utf-8'); session_start(); session_regenerate_id(); echo ' <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <metaname="viewport"content="width=device-width,height=device-height,initial-scale=1"> <title>Playlist</title> </head> <body> <form id="playlist" action="playlist_action.php" method="post"> <table id="playlist"> <caption>Play List</caption> <thead> <tr> <th scope="col">Voice SKU</th> <th scope="col">Voice Name</th> <th scope="col">Action</th> </tr> </thead> <tbody>'; foreach ($_SESSION['playlist'] as $key => $value) { $key = htmlspecialchars($key); echo ' <tr> <th scope="row">', $key, '</th> <td>', htmlspecialchars($value), '</td> <td><button name="delete" value="', $key, '">Delete</button></td> </tr>'; } echo ' </tbody> </table> </form> </body> </html> playlist_action.php <?php header('Content-Type: text/html; charset=utf-8'); session_start(); session_regenerate_id(); if (array_key_exists('playlist_action', $_POST)) { switch ($_POST['playlist_action']) { case 'delete': if (array_key_exists($_POST['delete'], $_SESSION['playlist']) { unset($_SESSION['playlist'][$_POST['delete']]); // notify user of successful delete } else { // notify user of non-existent key in the playlist } default: // handle invalid/unknown action here. } } ?> my output: |Parse error: syntax error, unexpected 'unset' (T_UNSET) in C:\wamp\www\voice_bank\playlist_action.php on line *10*|
  8. @Barand Did you mean -> document.getElementById('$key').remove(); ?
  9. @Barand If i click delete button whole list will be deleted, how to delete by single, <html> <head> <style type="text/css"> table { border-collapse: collapse; border: 1px solid black; } table td,th { border: 1px solid black; } td { text-align: center; } </style> </head> <body> <h2>Play Lists</h2> <table id="table"> <th>Voice SKU</th> <th>Voice Name</th> <th>Action</th> <?php session_start(); foreach ($_SESSION['playlist'] as $key => $value) { echo "<tr>"; echo "<td>" . $key . "</td>\n<td>" . $value . "</td>"; echo "<td>". "<button id='btn'>Delete</button>"."</td>"; echo "</tr>"; } ?> </table> <script> var btn = document.getElementById('btn'); btn.onclick = function () { document.getElementById('table').remove(); this.remove(); }; </script> </body> </html>
  10. @Barand If i ask any stupid question, make me a pardon, i am learning in php. <?php session_start(); foreach ($_SESSION['playlist'] as $key => $value) { echo "<tr>"; echo "<td>" . $key . "</td>\n<td>" . $value . "</td>"; echo "<td>" ."<button class='delbtn' data-id='"+ k +"'>Delete</button>" . "<td>"; echo "</tr>"; } ?> Pls correct me?
  11. @Barand That line okay, i got it, no confusion. My confusion about how can i use in below code, <?php session_start(); foreach ($_SESSION['playlist'] as $key => $value) { echo "<tr>"; echo "<td>" . $key . "</td>\n<td>" . $value . "</td>"; // code.... echo "</tr>"; } ?>
  12. @Barand For my clarification, this line -> "<td><button class='delbtn' data-id='"+ k +"'>Delete</button></td>"
  13. @Barand I just want to show playlist to other page, so i create view_cart.php : <html> <head> <style type="text/css"> table { border-collapse: collapse; border: 1px solid black; } table td,th { border: 1px solid black; } td { text-align: center; } </style> </head> <body> <h2>Play Lists</h2> <table> <th>Voice SKU</th> <th>Voice Name</th> <?php session_start(); foreach ($_SESSION['playlist'] as $key => $value) { echo "<tr>"; echo "<td>" . $key . "</td>\n<td>" . $value . "</td>"; echo "</tr>"; } ?> </table> </body> </html> I have passed both voice_sku and voice_name to view_cart.php, here how can i pass along with delete option. Output:
  14. Finally working after changes the value sku to voice_sku and name to voice_name in JS.
  15. @Barand FYI -> here i changed my_cart.php to manage_cart.php & voice_id to voice_sku Main PHP file, <?php session_start(); if (isset($_SESSION['playlist'])) { echo '<pre>', print_r($_SESSION['playlist'], 1), '</pre>'; echo "</hr><br>\n"; } include('database_connection.php'); // start Custom filter if(isset($_POST["action"])) { $query = " SELECT * FROM voice_bank_data WHERE voice_status = '1' "; // 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."') "; } // end Custom 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;"> 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" type="submit" 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; } ?> <html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $().ready( function() { $(".btn").click( function() { var vid = $(this).data("sku"); var vname = $(this).data("name"); $.post( "manage_cart.php", { "voice_sku" : vid, "voice_name" : vname, "action" : "Add" }, function(resp) { outputPlaylist(resp) }, "JSON" ) }) function outputPlaylist(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>" list = list + "<td><button class='delbtn' data-id='"+ k +"'>Delete</button></td></tr>\n" // add "Delete" button to each playlist item }) $("#playlist").html(list) // define action for new delbtn's $(".delbtn").click( function() { var vid = $(this).data("sku"); $.post( "manage_cart.php", { "voice_sku" : vid, "action" : "Delete"}, function(resp) { outputPlaylist(resp) }, "JSON" ) }) } }) </script> </head> <body> <h2>Playlists...</h2> <table style="width:600px" id="playlist"> </table> </body> </html> manage_cart.php (prior - my_cart.php) <?php session_start(); if ($_SERVER['REQUEST_METHOD']=='POST') { $voice_sku = $_POST['$voice_sku'] ?? 0; $action = $_POST['action'] ?? ''; if ($action == 'Delete') { // we are deleting the item from the session array if ($voice_sku) { unset($_SESSION['playlist'][$voice_sku]); exit(json_encode($_SESSION['playlist'])) ; } } elseif ($action == 'Add') { // we are adding the item $voice_name = $_POST['voice_name'] ?? ''; if ($voice_sku && $voice_name) { $_SESSION['playlist'][$voice_sku] = $voice_name; exit(json_encode($_SESSION['playlist'])) ; } } else { exit("ERROR") ; } } exit("ERROR") ; ?> Expected output : added to playlists actual output : Not added to playlist output : How to solve the error?
  16. @Barand How to delete individual row like -> https://jsfiddle.net/annoyingmouse/7c0v1ra3/
  17. *Finally done, sorry for lots of reply, i can't able to delete.
  18. How can i use my $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> '; instead of, <body> Song 1 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="1" data-name="song-1.mp3">Add to PlayList </button> <br> Song 2 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="2" data-name="song-2.mp3">Add to PlayList </button> <br> Song 3 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="3" data-name="song-3.mp3">Add to PlayList </button> <br> Song 4 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="4" data-name="song-4.mp3">Add to PlayList </button> <br> Song 5 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="5" data-name="song-5.mp3">Add to PlayList </button> <br> Song 6 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="6" data-name="song-6.mp3">Add to PlayList </button> <br> <br> <h2>Playlist</h2> <table style="width:600px" id="playlist"> </table> </body>
  19. FYI -> Neglect last reply, here is my complete code : fetch_data.php <?php session_start(); if (isset($_SESSION['playlist'])) { echo '<pre>', print_r($_SESSION['playlist'], 1), '</pre>'; echo "</hr><br>\n"; } //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;"> 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; } ?> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $().ready( function() { $(".btn").click( function() { var vid = $(this).data("id"); var vname = $(this).data("name"); $.post( "my_cart.php", { "voice_id" : vid, "voice_name" : vname}, 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> </head> <body> Song 1 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="1" data-name="song-1.mp3">Add to PlayList </button> <br> Song 2 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="2" data-name="song-2.mp3">Add to PlayList </button> <br> Song 3 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="3" data-name="song-3.mp3">Add to PlayList </button> <br> Song 4 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="4" data-name="song-4.mp3">Add to PlayList </button> <br> Song 5 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="5" data-name="song-5.mp3">Add to PlayList </button> <br> Song 6 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="6" data-name="song-6.mp3">Add to PlayList </button> <br> <br> <h2>Playlist</h2> <table style="width:600px" id="playlist"> </table> </body> </html> My_cart.php <?php session_start(); if ($_SERVER['REQUEST_METHOD']=='POST') { $voice_id = $_POST['voice_id'] ?? 0; $voice_name = $_POST['voice_name'] ?? ''; if ($voice_id && $voice_name) { $_SESSION['playlist'][$voice_id] = $voice_name; exit(json_encode($_SESSION['playlist'])) ; } } exit("ERROR") ; ?> output is ERROR.
  20. @Barand I just try, i am new to PHP, if i did any stupid things, make me a pardon,
  21. @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 :
  22. @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?
  23. 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>
×
×
  • 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.