Product URL only shown after purchase

  • Posts: 14
  • Thank you received: 0
13 years 7 months ago #14808

I am selling digital books with a downloadable copy and a copy that is viewable on the site. I figured out how to do the regular downloadable file on the product, but now I need to be able to also post a URL that the customer can see and "View" when they log in to their account after purchasing. This "View" link would then take them to the HTML file that will display the Flash file of the book.

I am using the free version of HikaShop on Joomla 1.6. I don't have a problem adding code in order to achieve this, but I don't know what code or where to add it.

Thanks in advance for you help.

Last edit: 13 years 7 months ago by snatrott.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 7 months ago #14819

What you could do is to create a new menu item only accessible to a certain group of users (you can create new groups in the joomla user manager). Then, on your product edition screen at the left bottom of the screen, with the Business version of HikaShop, you can select a group of users to which the user will be added once he buys the product. Thus, that will enable him to access to your menu item.

Last edit: 13 years 7 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 7 months ago #14837

That won't work because it should only be accessible to the person that ordered that specific book.

I am thinking though that it might be achievable by editing the view files. I could remove the Product URL from the product description and have it display in the orders area with the download link. I am unable to test this theory because of another issue, though. I edit a file under Display->Views, hit Save and then check the file and all my changes are gone. It says "Successfully Saved", but I changed it probably 30 times before it finally saved the changes on just the one file. I haven't been able to get any others to keep the changes even after dozens of tries.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 7 months ago #14843

If you have several templates on your website, you should have several times the view files, one per template. Please make sure that you're editing the correct file for the correct template.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 7 months ago #14846

I only have 2 templates on my site (the admin one and the front end one), and I filtered them to only show the ones for the front end template. Also, I clicked on the exact same file right after saving and the changes are gone.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 7 months ago #14851

Then, maybe there is a glitch with the file saving process. It's handled by joomla. If it doesn't work it's probably because of an access right issue.

What strange is that you're saying that it works sometimes...
In all cases, you can always copy the view files from components/com_hikashop/views to templates/YOUR_TEMPLATE/html/com_hikashop via FTP and make your modifications directly without using the interface...

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 7 months ago #14858

Awesome. I copied them over to my template directory and was able to save my changes in them. I tried just copying the Product URL code from the Product Show file, but it didn't work.

<span id="hikashop_product_url_main" class="hikashop_product_url_main">

			<?php 

			if(!empty($this->element->product_url)){

				echo JText::sprintf('MANUFACTURER_URL','<a href="'.$this->element->product_url.'" target="_blank">'.$this->element->product_url.'</a>');

			} ?>

		</span>

What do I need to change to make the URL display on the Order Show page?

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 7 months ago #14859

None of the PHP code displayed in that last post, but it is everything in file views/product/tmpl/show.php from lines 364 to 374.

<span id="hikashop_product_url_main" class="hikashop_product_url_main">

			< ? php 

			if(!empty($this->element->product_url)){

				echo JText::sprintf('MANUFACTURER_URL','<a href="'.$this->element->product_url.'" target="_blank">'.$this->element->product_url.'</a>');

			} ? >

		</span>

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 7 months ago #14860

You can just replace $this->element by $product in that code and put it inside the foreach($this->order->products as $product) of the order show view file

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 7 months ago #14861

Here is my current code in the order show file that isn't displaying any URL:

< ? php
							$k=0;
							global $Itemid;
							$url = '';
							if(!empty($Itemid)){
								$url='&Itemid='.$Itemid;
							}		foreach($this->order->products as $product){

			if(!empty($product->product_url)){

				echo JText::sprintf('MANUFACTURER_URL','<a href="'.$product->product_url.'" target="_blank">'.$product->product_url.'</a>');

			}

								? >

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 7 months ago #14862

Would there be a way to make a view that just shows the products that someone has downloaded in their history and skip the step of having to go look at each order to see all the products ordered?

I would like someone to be able to login and click a menu link such as "My Digital Products" and see all of their purchased digital downloads and the URLs that go with them. Instead of an Order Listing, I want a Product Listing of just purchased products for that particular user.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 7 months ago #14873

You might have to load the data of the product:
$p = hikashop::get('class.product');
$data = $p->get($product->product_id);

and then use $data instead of $product in your code.

Also not that the foreach is inside a table tag. so you need to add tr and td tags or move your code around so that it displays inside a tr td.


If you want to have a specific view listing the downloadable files of the user, there is no such feature in hikashop. You either need to write it or ask someone to develop it for you. We can propose such development. If you're interested, you can use our contact form to request a quote:
www.hikashop.com/en/support/contact-us.html

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 4 months ago #20122

I had to take some time off this project, but now I am back. :)

I am working on just displaying the Manufacturer URL in the Order view. I am editing the Order->Show page. I want the product code (and/or product name) to be a link to the manufacturer URL.

This is the section of code I want to change:

<?php if($this->invoice_type=='order' && !empty($product->product_id)){ ?>
<a class="hikashop_order_product_link" href="<?php echo hikashop::completeLink('product&task=show&cid='.$product->product_id.$url); ?>">
<?php } ?>
<p class="hikashop_order_product_name"><?php echo $product->order_product_name; ?></p>
<p class="hikashop_order_product_code"><?php echo $product->order_product_code; ?></p>
<?php if($this->invoice_type=='order' && !empty($product->product_id)){ ?>
</a>

I have tried several different ways of writing the link, but none of them have been successful so I am back to square one. The code for the title link looks like it references the URL, but it doesn't ever go to the manufacturer URL.

Ideally, I would like to just change this section:
href="<?php echo hikashop::completeLink('product&task=show&cid='.$product->product_id.$url); ?>"
to point to the manufacturer URL.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 4 months ago #20124

This is the section of code I want to change:

< ? php if($this->invoice_type=='order' && !empty($product->product_id)){ ? >
<a class="hikashop_order_product_link" href="<?php echo hikashop::completeLink('product&task=show&cid='.$product->product_id.$url); ?>">
< ? php } ? >
<p class="hikashop_order_product_name"><?php echo $product->order_product_name; ?></p>
<p class="hikashop_order_product_code"><?php echo $product->order_product_code; ?></p>
< ? php if($this->invoice_type=='order' && !empty($product->product_id)){ ? >
</a>
Ideally, I would like to just change this section:
<a class="hikashop_order_product_link" href="< ? php echo hikashop::completeLink('product&task=show&cid='.$product->product_id.$url); ? >">

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20131

You should try something like that instead:

<a class="hikashop_order_product_link" href="<?php echo $product->product_url; ?>" target="_blank"><?php echo $product->product_url; ?></a>

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 4 months ago #20157

I tried that and the link shows up as: www.mydomain.com/$product- >product_url

The link doesn't actually display the product url.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20169

That's not possible. Could you double check that you used the same code as I wrote ?

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 4 months ago #20325

I just copied and pasted your code and the link goes to domain.com/$product- >product_url

The full code from my Order Show page for the product display table is:

<table cellpadding="1" width="100%">
						<thead>
							<tr>
								<th class="hikashop_order_item_name_title title">
									< ? php echo JText::_('PRODUCT'); ? >
								</th>
								<th class="hikashop_order_item_files_title title">
									< ? php echo JText::_('HIKA_FILES'); ? >
								</th>
								<th class="hikashop_order_item_price_title title">
									< ? php echo JText::_('UNIT_PRICE'); ? >
								</th>
								<th class="hikashop_order_item_quantity_title title titletoggle">
									< ? php echo JText::_('PRODUCT_QUANTITY'); ? >
								</th>
								<th class="hikashop_order_item_total_title title titletoggle">
									< ? php echo JText::_('PRICE'); ? >
								</th>
							</tr>
						</thead>
						<tbody>
						< ? php
							$k=0;
							global $Itemid;
							$url = '';
							if(!empty($Itemid)){
								$url='&Itemid='.$Itemid;
							}
							foreach($this->order->products as $product){
								? >
								<tr class="row<?php echo $k;?>">
									<td class="hikashop_order_item_name_value">
										< ? php if($this->invoice_type=='order' && !empty($product->product_id)){ ? >
											<a class="hikashop_order_product_link" href="< ? php echo hikashop::completeLink('product&task=show&cid='.$product->product_id.$url); ? >">
										< ? php } ? >
										<p class="hikashop_order_product_name">< ? php echo $product->order_product_name; ? ></p>
										<p class="hikashop_order_product_code">< ? php echo $product->order_product_code; ? ></p>
										< ? php if($this->invoice_type=='order' && !empty($product->product_id)){ ? >
										</a>
		<span id="hikashop_product_url_main" class="hikashop_product_url_main">

			<a class="hikashop_order_product_link" href="< ? php echo $product->product_url; ? >" target="_blank">View</a>

		</span>
										< ? php } 

										if($this->invoice_type=='order'){ ? >

										<p class="hikashop_order_product_custom_item_fields">
										< ? php 
										if(hikashop::level(2) && !empty($this->fields['item'])){
											foreach($this->fields['item'] as $field){
												$namekey = $field->field_namekey;
												echo '<p class="hikashop_order_item_'.$namekey.'">'.$this->fieldsClass->getFieldName($field).': '.$this->fieldsClass->show($field,$product->$namekey).'</p>';
											}
										}?>
										</p>
										<?php }? >
									</td>
									< ? php if($this->invoice_type=='order' && !empty($product->files)){ ? >
									<td class="hikashop_order_item_files_value">
										< ? php 
										if($this->order_status_download_ok || bccomp($product->order_product_price,0,5)==0){
											$html = array();
											foreach($product->files as $file){
												if(empty($file->file_name)){
													$file->file_name = $file->file_path;
												}
												$fileHtml = '';
												if(!empty($this->download_time_limit) && ($this->download_time_limit+$this->order->order_created)<time()){
													$fileHtml = JText::_('TOO_LATE_NO_DOWNLOAD');
												}
												if(!empty($this->download_number_limit) && $this->download_number_limit<=$file->download_number){
													$fileHtml = JText::_('MAX_REACHED_NO_DOWNLOAD');
												}
												if(empty($fileHtml)){
														$fileHtml = '<a href="'.hikashop::completeLink('order&task=download&file_id='.$file->file_id.'&order_id='.$this->order->order_id).'"><img src="images/download.png" alt="Download" /></a>';
														if(!empty($this->download_time_limit))$fileHtml .= ' / '.JText::sprintf('UNTIL_THE_DATE',hikashop::getDate($this->order->order_created+$this->download_time_limit));
														if(!empty($this->download_number_limit))$fileHtml .= ' / '.JText::sprintf('X_DOWNLOADS_LEFT',$this->download_number_limit-$file->download_number);
												}else{
													$fileHtml = $file->file_name .' '.$fileHtml;
												}
												$html[]=$fileHtml;
											}
											echo implode('<br/>',$html);
										}
										? >
									</td>
									< ? php } ? >
									<td class="hikashop_order_item_price_value">
									< ? php echo $this->currencyHelper->format($product->order_product_price,$this->order->order_currency_id);? >
									</td>
									<td class="hikashop_order_item_quantity_value">
										< ? php echo $product->order_product_quantity;? >
									</td>
									<td class="hikashop_order_item_total_value">
										< ? php echo $this->currencyHelper->format($product->order_product_total_price_no_vat,$this->order->order_currency_id);? >
									</td>
								</tr>
								< ? php 
								$k=1-$k;
							} 
						? >
							<tr>
								<td style="border-top:2px solid #B8B8B8;" colspan="< ? php echo $colspan; ? >">
								</td>
								<td class="hikashop_order_subtotal_title" style="border-top:2px solid #B8B8B8;" class="key">
									<label>
										< ? php echo JText::_( 'SUBTOTAL' ); ? >
									</label>
								</td>
								<td class="hikashop_order_subtotal_value" style="border-top:2px solid #B8B8B8;">
									< ? php echo $this->currencyHelper->format($this->order->order_subtotal_no_vat,$this->order->order_currency_id); ? >
								</td>
							</tr>
							<tr>
								<td colspan="< ? php echo $colspan; ? >">
								</td>
								<td class="hikashop_order_tax_title key">
									<label>
										< ? php echo JText::_( 'VAT' ); ? >
									</label>
								</td>
								<td class="hikashop_order_tax_value">
									< ? php echo $this->currencyHelper->format($this->order->order_subtotal-$this->order->order_subtotal_no_vat,$this->order->order_currency_id); ? >
								</td>
							</tr>
							<tr>
								<td colspan="< ? php echo $colspan; ? >">
								</td>
								<td class="hikashop_order_coupon_title key">
									<label>
										< ? php echo JText::_( 'HIKASHOP_COUPON' ); ? >
									</label>
								</td>
								<td class="hikashop_order_coupon_value" >
									< ? php echo $this->currencyHelper->format($this->order->order_discount_price*-1.0,$this->order->order_currency_id); ? >
								</td>
							</tr>
							<tr>
								<td colspan="< ? php echo $colspan; ? >">
								</td>
								<td class="hikashop_order_shipping_title key">
									<label>
										< ? php echo JText::_( 'SHIPPING' ); ? >
									</label>
								</td>
								<td class="hikashop_order_shipping_value" >
									< ? php echo $this->currencyHelper->format($this->order->order_shipping_price,$this->order->order_currency_id); ? >
								</td>
							</tr>
							<tr>
								<td colspan="< ? php echo $colspan; ? >">
								</td>
								<td class="hikashop_order_total_title key">
									<label>
										< ? php echo JText::_( 'HIKASHOP_TOTAL' ); ? >
									</label>
								</td>
								<td class="hikashop_order_total_value" >
									<?php echo $this->currencyHelper->format($this->order->order_full_price,$this->order->order_currency_id); ?>
								</td>
							</tr>
						</tbody>
					</table>

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
13 years 4 months ago #20326

Ok, I think we can all agree that I am terrible with posting the code. Just let me know if you want to see the full code. I previewed my post and it was fine, so I don't know what happened to it.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20341

You wrote the code:
< ? php echo $product->product_url; ? >

instead of the code:
<?php echo $product->product_url; ?>

Because of the spaces you added in the tags, it doesn't work properly.

Please Log in or Create an account to join the conversation.

Time to create page: 0.069 seconds
Powered by Kunena Forum