Post by geniusroi » Sat May 26, 2018 9:09 pm

I need to change the price dynamically in my website based on the option selected.
(Example: http://www.hejazoud.net/index.php?route ... uct_id=394)

I tried multiple extensions like this one (Ajax Live Options) but nothing work.

Is there any extension or code to fulfil this?

Does using a theme different from the default one affect this? If so, do I need to change anything?

OpenCart version: 2.2.0.0

Newbie

Posts

Joined
Sun Mar 26, 2017 8:29 pm

Post by yodapt » Sat May 26, 2018 9:24 pm

geniusroi wrote:
Sat May 26, 2018 9:09 pm
Does using a theme different from the default one affect this? If so, do I need to change anything?
It might depending on the theme. It's hard to tell what needs to be changed, as it might also interfere with other extensions. PM me if you need commercial assistance.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by IP_CAM » Sun May 27, 2018 7:36 am

It's one of the most difficult OC-Extension, as fas as I found out.
I had only one of the Mods working in one of my test designs a
while ago, but never was able to make it work again in other Layouts.
It's probably the script, wich somehow collides with other routines.
So I delayed this so easy looking function, until everthing else works
as planned. So, you're not alone... :D
Ernie

Ernie's OpenCart v.1.5.6.5 LIGHT + V-Pro + OpenShop Admin v.1.75 Test Sites
http://www.bigmax.ch - http://www.opencart.li/shop/
Image


User avatar
Guru Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by geniusroi » Sun May 27, 2018 11:09 pm

I wrote this solution using jquery, which might not be ideal, but I think it works regardless of version and template changes.

Code: Select all

<script type="text/javascript">

$( "select" )
  .change(function() {
    var str = "";
    $( "select option:selected" ).each(function() {
      str =str.substring(str.lastIndexOf("(")+1,str.lastIndexOf(")"));
      str += " السعر:" + $( this ).text().split('(').pop().split(')').shift() + "ريال";
    });
    $( ".special-price" ).text( str );
  })
  .trigger( "change" );
</script>

</script>

I hope it helps other people who wants to achieve this result.

Newbie

Posts

Joined
Sun Mar 26, 2017 8:29 pm

Post by IP_CAM » Mon May 28, 2018 12:50 am

well, possibly after one finds out, what those two funny words mean ... :laugh:

Code: Select all

str += " السعر:" + $( this ).text().split('(').pop().split(')').shift() + "ريال";

Ernie's OpenCart v.1.5.6.5 LIGHT + V-Pro + OpenShop Admin v.1.75 Test Sites
http://www.bigmax.ch - http://www.opencart.li/shop/
Image


User avatar
Guru Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by geniusroi » Mon May 28, 2018 5:10 pm

IP_CAM wrote:
Mon May 28, 2018 12:50 am
well, possibly after one finds out, what those two funny words mean ... :laugh:

Code: Select all

str += " السعر:" + $( this ).text().split('(').pop().split(')').shift() + "ريال";
"Price" and "Riyal" in Arabic, but you can change them with any words or symbols.

Newbie

Posts

Joined
Sun Mar 26, 2017 8:29 pm
Who is online

Users browsing this forum: Google [Bot] and 22 guests