Jump to content

iammabbella

Members
  • Posts

    10
  • Joined

  • Last visited

Profile Information

  • Activity
    Freelancer

iammabbella's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I have resolved with this query: $this->result_ticket = Db::getInstance()->getValue(' SELECT SUM(cp.quantity) FROM '._DB_PREFIX_.'cart_product cp INNER JOIN '._DB_PREFIX_.'product p ON cp.id_product = p.id_product WHERE p.reference = "'.$reference_variable.'" AND cp.id_cart = '.$this->context->cart->id.' '); Works great! However this pull out the number of tickets in the cart (with sum), who have the field reference value equal to "accessorio", and throws the result in order-address.tpl.
  2. Without the "LEFT" works, however it's strange that return always the value 1, even though there are more products with the keyword "accessorio". SELECT COUNT(DISTINCT p.id_product) FROM ps_cart_product cp JOIN ps_product p WHERE cp.id_cart = 84 AND p.reference = "accessorio" Return 2 in phpmyadmin, but in Presta return 1... Ps. Scusa se te lo domando, ma sei italiano??
  3. There still is the error, I really don't know what's going on, never happen with my own classe that I create for db access. What's wrong? You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE cp.id_cart = 84 AND p.reference = "accessorio"' at line 4 SELECT COUNT(DISTINCT p.id_product) FROM ps_cart_product cp LEFT JOIN ps_product p WHERE cp.id_cart = 84 AND p.reference = "accessorio" at line 605 in file classes/db/Db.php
  4. I used exactly your code, with this line AND p.reference = '.$reference_variable); Is the debug of Prestashop that write the variable, but in code is like above.
  5. I get an error... You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE cp.id_cart = 84 AND p.reference = accessorio' at line 4 SELECT COUNT(DISTINCT p.id_product) FROM ps_cart_product cp LEFT JOIN ps_product p WHERE cp.id_cart = 84 AND p.reference = accessorio at line 605 in file classes/db/Db.php
  6. The latest one maybe, today I'm gonna test this solution, then I'll tell you what's the result. Thanks a lot for now...
  7. "I assume you only need to check that with products inside the cart": Yes u are right..! That's a good solution, but where could I put this code, in which page I mean... not in .tpl file, or am I wrong? I love code in pure php, directly, normally if I had a problem like this in php, I would have resolved that in little time, but with Smarty and the "Presta code architecture" I'm stuck with no time for learn
  8. Hello, I'm super new to Prestashop, I need to obtain in the page "order-address.tpl" the total number of products (I'm in the checkout procedure, so only the products the client "is buying") with a certain field reference, for instance "accessory-nano". I've already the total number of products, but I need only this value, just a numeric value. Is it possible? For now I have $productNumber (the products total).
×
×
  • Create New...