Jump to content

aveeva

Members
  • Content Count

    63
  • Joined

  • Last visited

Community Reputation

0 Neutral

About aveeva

  • Rank
    Regular Member
  1. I am developed a custom PHP page with filters, addto cart module, music playlist everything. How can i implement it into WordPress? I am a newbie, any help thanks. My custom PHP work directory structure : location : public_html/my_work website URL : website.com/my_work Everything working good, but my wordpress heaer and footer missing, thats what i am asking to how to implement my custom development multiple PHP page work into Wordpress.
  2. I dont want unset onclick="this.disabled=true" if page refresh, code : <button type="button" class="addb btn btn-primary rounded-pill py-2 btn-block" type="submit" data-voice_sku="'.$row["voice_sku"].'" data-voice_name="'.$row["voice_name"].'" onclick="this.disabled=true">Add to Playlist</button> If page refresh onclick event unset. how to prevent?
  3. 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
  4. 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?
  5. 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>
  6. @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";}
  7. 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'); } } ?>
  8. @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
  9. 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*|
  10. @Barand Did you mean -> document.getElementById('$key').remove(); ?
  11. @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>
  12. @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?
  13. @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>"; } ?>
  14. @Barand For my clarification, this line -> "<td><button class='delbtn' data-id='"+ k +"'>Delete</button></td>"
×
×
  • 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.