Post by stepsecr » Fri Jul 22, 2016 5:02 pm

Hi all

Given an example:
http://www.techarmory.my/index.php?rout ... uct_id=184

I have alot of options for our customer to select the product that they want, but it's very inconvenient that the sub total is always on the top so each time customer pick some selection he/she has to go all the way top of the page to check the total price.

So wondering if there is any modules that can allow me to set a floating subtotal on center right of the screen, as the user scroll, the price floats accordingly.

please advise. thanks

Newbie

Posts

Joined
Fri Jul 22, 2016 4:55 pm

Post by straightlight » Fri Jul 22, 2016 10:23 pm

Welcome to the Opencart forum. Interesting request ...

followed is an attached VQMod file and an example on this post for the default theme for Opencart v2.2.0.0 release. If you are using a custom theme, you'd find to find a way to fit it in.

In your catalog/view/theme/default/template/checkout/cart.tpl file,

find:

Code: Select all

<?php echo $footer; ?>
add right above:

Code: Select all

<script type="text/javascript"><!--
	$(document).ready(function() {
		// set the offset pixels automatically on how much the sidebar height is.
		// plus the top margin or header height
		var offsetPixels = $('.sidebarBox').outerHeight() + 30;
		$(window).scroll(function() {
			if ( $(window).scrollTop() > offsetPixels ) {
				$('.scrollingBox').css({
					'position': 'fixed',
					'bottom': '300px',
					'right': '40px',
					'background': '#ff9900',
					'font-weight': 'bold',
					'color': '#ffffff',
					'border': '1px solid #ccc',
					'padding': '10px',
					'margin-bottom': '20px'
				});
			} else {
				$('.scrollingBox').css({
					'position': 'static'
				});
			}
		});
	});
//--></script>
Then, find the second instance of:

Code: Select all

<div class="row">
add above:

Code: Select all

<?php $sub_totals = 0.0; ?>
Then, find:

Code: Select all

<?php foreach ($totals as $total) { ?>
add right below:

Code: Select all

<?php if (trim(strtolower($total['code'])) == 'sub_total') { ?>
				 <?php $sub_totals = $total['title'] . ': ' . $total['text']; ?>
			<?php } ?>
Then, find the second instance of:

Code: Select all

</table>
add below:

Code: Select all

<div class="sidebarBox">
			  <div class="scrollingBox">
				<?php echo $sub_totals; ?>
			  </div>
		  </div>
This should resolved the problem. Feel free to adjust the looks and feels from the CSS in the jQuery codes. :)

Note: If you are not familiar with either OCMod / VQMod extensions, I would suggest to read: http://docs.opencart.com for more information. Also, you can visit: http://www.vqmod.com to use XML files and also OCMod extensions usable from the admin - > extensions - > installer and extensions page.

Attachments

Sub-Total Floating


Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by stepsecr » Sat Jul 23, 2016 6:32 pm

hi


What if i need the float to be view before a customer confirm an order into the cart?
Given an example as the link below:
https://www.aftershockpc.com/welcome/Pr ... ner/m15-v2

when ever a user change the option, the reflected price shown will be always float and align center of the screen

Thanks

Newbie

Posts

Joined
Fri Jul 22, 2016 4:55 pm

Post by straightlight » Sat Jul 23, 2016 6:41 pm

stepsecr wrote:hi


What if i need the float to be view before a customer confirm an order into the cart?
Given an example as the link below:
https://www.aftershockpc.com/welcome/Pr ... ner/m15-v2

when ever a user change the option, the reflected price shown will be always float and align center of the screen

Thanks
The subtotal is only calculated based on the total of all added prices to the cart. Based on your first post and subject, you wish to have a module for floating based on the sub-total price. Not on each product price before they add a product to the cart.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by stepsecr » Mon Jul 25, 2016 11:53 pm

Hi.

sorry for confusion earlier. My expression is not very good.

My goal and aim is to add a floating TOTAL PRICE on the product page, but not on the checkout

could you guide me? i am a self learner and i not very good in coding yet

thanks

Newbie

Posts

Joined
Fri Jul 22, 2016 4:55 pm

Post by straightlight » Tue Jul 26, 2016 12:07 am

stepsecr wrote:Hi.

sorry for confusion earlier. My expression is not very good.

My goal and aim is to add a floating TOTAL PRICE on the product page, but not on the checkout

could you guide me? i am a self learner and i not very good in coding yet

thanks
The order totals are specifically loaded from the cart page and on the checkout page, by default - which both includes the sub-total. Could you elaborate on how exactly do you intend to calculate the sub-total with a simple sales price from the product page?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by stepsecr » Tue Jul 26, 2016 12:34 am

Hi

thanks for the quick feedback.
Okay, like this, under the URL :
http://www.techarmory.my/index.php?rout ... uct_id=182
i need these
Image
info to be float on the product page when customer scroll further down to change some option

And yes i think i am using custom theme with auto price adder.

i think i amended the code by follow the suggestion you gave but i not manage to make it work on product page. Which i guess i don't understand how to amend the below option price changer, and it's code as below:

Code: Select all

<?php foreach ($option['product_option_value'] as $option_value) { ?>
																	<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
																	<?php if ($option_value['price']) { ?>
																	(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)

thanks

Newbie

Posts

Joined
Fri Jul 22, 2016 4:55 pm
Who is online

Users browsing this forum: No registered users and 11 guests