Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How To Check If User Purchased An Item On The Product Page Rate Topic   - - - - -

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22171 posts

Posted 29 January 2021 - 04:39 AM #21

I managed to get the text to show "you bought this item", please how can i show the <a> hink to the order in the product page?

 

Return $order_id in the function and use something like

 

{$purchaed_before=$product.product_id|my_purchased_before}
{if $purchased_before}
  <p><a href="{"orders.details?order_id=`$purchased_before`"|fn_url}">{$purchased_before nofilter}</a></p>
{/if}

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 339 posts

Posted 29 January 2021 - 07:18 AM #22

 

Return $order_id in the function and use something like

 

{$purchaed_before=$product.product_id|my_purchased_before}
{if $purchased_before}
  <p><a href="{"orders.details?order_id=`$purchased_before`"|fn_url}">{$purchased_before nofilter}</a></p>
{/if}

 

I tried to return the order_id with the code generously provided by tbirnseth, return db_get_field("SELECT order_id FROM ?:orders AS o INNER JOIN ?:order_details AS od ON o.order_id=od.order_id AND od.product_id=?i WHERE o.user_id=?i ORDER BY order_id DESC", $product_id, $user_id); but it's causing an error



 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 339 posts

Posted 05 February 2021 - 02:37 PM #23

 

Return $order_id in the function and use something like

 

{$purchaed_before=$product.product_id|my_purchased_before}
{if $purchased_before}
  <p><a href="{"orders.details?order_id=`$purchased_before`"|fn_url}">{$purchased_before nofilter}</a></p>
{/if}

 

 

Do you happen to have a suggestion on how to properly return the order id on the product page?



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12091 posts

Posted 05 February 2021 - 07:03 PM #24

If you're using the code I provided and put it in a function, you just need to return $order_id and then use the return value.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 339 posts

Posted 05 February 2021 - 11:26 PM #25

If you're using the code I provided and put it in a function, you just need to return $order_id and then use the return value.

 

 

Yes, here's what i did but it's not working

 

function my_check_previous_order($product_id, $user_id) {
$product_id = $_REQUEST['product_id'];
$user_id = $_SESSION['auth']['user_id'];
if(empty($user_id) || empty($product_id)) { return false; }
  return db_get_field("SELECT count(od.product_id) FROM ?:orders AS o LEFT JOIN ?:order_details AS od ON od.order_id=o.order_id AND od.product_id=?i WHERE o.user_id=?i", $product_id, $user_id);
 
//this is what's not working
return db_get_field("SELECT order_id FROM ?:orders AS o INNER JOIN ?:order_details AS od ON o.order_id=od.order_id AND od.product_id=?i WHERE o.user_id=?i ORDER BY order_id DESC", $product_id, $user_id);
}


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12091 posts

Posted 06 February 2021 - 07:03 PM #26

If you are using a function with parameters of $product_id and $user_id, why are you setting them to global variables?

I have no  idea of what you're truing to do based on the code you are providing.  Also, please put code inside "code" tags so it's readable.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 339 posts

Posted 07 February 2021 - 05:54 PM #27

If you are using a function with parameters of $product_id and $user_id, why are you setting them to global variables?

I have no  idea of what you're truing to do based on the code you are providing.  Also, please put code inside "code" tags so it's readable.

 

yes, I'm trying to find out how to show the order url on the product page at the moment it's showing "you bought this item" but the link to the order is not working because the order id is not returned in the href



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12091 posts

Posted 07 February 2021 - 08:51 PM #28

sorry, I've already freely provided all that I can in support of your endeavor.  

Again, I strongly suggest you hire a developer to help you.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 339 posts

Posted 12 February 2021 - 12:38 PM #29

Does it mean there's no way to get the order id on the product page?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22171 posts

Posted 12 February 2021 - 01:02 PM #30

Does it mean there's no way to get the order id on the product page?

 

Of course, it is possible


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 339 posts

Posted 13 February 2021 - 12:48 AM #31

Of course, it is possible

 

How can i do it please, that's the only thing hindering the href link from working.

 

<a href="{"orders.details?order_id=`$purchased_before_order_id`"|fn_url}">view the order details</a>

 

how can i return this variable $purchased_before_order_id in the product page



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22171 posts

Posted 15 February 2021 - 07:21 AM #32

Please check post #28


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)