Remove original price from the addition of optional value price - opencart

Pleas help me out for this minor issues.
I want to remove the original value price from the addition of total optional value price from the cart in OpenCart 3.0.
Reference URL.
When you add option and hit add to cart. After when we open the cart symbol at top right cart, the original price also added.
UPDATED
Thanks for your reply.
I want to display minimum price on home page. So, can I show the product's minimum price from the optional value.
For Example: I have three varieties of products.
Prod 1 ($10)
Prod 2 ($20)
Prod 3 ($30)
I want to display Prod 1 ($10) on my home page. That's it. How to do that?
Appreciate your reply..

In this case you can set original price to 0.
or
You can set main product price = to minimal option price, then set your option prices like:
+0
+10
+20
That's how options in OpenCart works.
UPDATED
Set your product price to $10. Then set your options' prices to:
+0
+10
+20
UPDATE 2
Using previous update, to see full price in option lets make following changes:
open catalog/controller/product/product.php, find
$product_option_value_data[] = array(
'product_option_value_id' => $option_value['product_option_value_id'],
'option_value_id' => $option_value['option_value_id'],
'name' => $option_value['name'],
'image' => $this->model_tool_image->resize($option_value['image'], 50, 50),
'price' => $price,
'price_prefix' => $option_value['price_prefix']
);
This line
'price' => $price,
replace with
'price' => $this->currency->format($option_value['price'] + $product_info['price'], $this->session->data['currency']),
Update your ocmod cache and now you will see (main price + option price) value in options on product page. And set you option from chackbox to radio.

Related

Select list display issue

Good morning,
within Oracle Apex Application Builder I'm trying to create a order product page which displays products from a product table, shows a select list which a user can use to define the quantity in which they want to order. Using a classic report to display my code, the declared table columns were generated and outputted on the report, however the select list column only shows the html syntax used to create a select list and not the actual drop down select list with values.
Here is the code:
select p.product_id,
p.product_name,
p.product_price,
apex_item.hidden(1, p.product_id) ||
apex_item.hidden(2, p.product_price) ||
apex_item.select_list(
p_idx => 3,
p_value => nvl(c.c003,'Add_to_cart'),
p_list_values => '1,2,3,4,5,6,7,8,9,10',
p_show_null => 'YES',
p_null_value => 0,
p_null_text => '0',
p_item_id => 'f03_#ROWNUM#',
p_item_label => 'f03_#ROWNUM#',
p_show_extra => 'NO') "add_to_cart"
from prod p, apex_collections c
WHERE c.collection_name (+) = 'ORDER_ITEMS'
and c.c001 (+) = p.product_id
Can someone explain why this is happening, how to correct my issue and if there are better ways to implement a select list; as I need this code to work for my project?
Thanks in-advance for the help!
In Builder, navigate to that column so that you'd see its properties. Scroll down to Escape special characters and set it to "No". Then run the report and see whether there's any improvement (should be).

Select sum and dynamic where statement query in Rails 4

I have this below statement in my controller and I want to know how to rewrite it in Rails 4
Entry.find(:all, :conditions => [#conditions.keys.join(" AND "), *#conditions.values],:group => "user_id", :select => "SUM(time_spent) AS total_spent")
The condition has the user_id information in it like "user_id=?".
The statement is trying to find the entry for a particular user id and sum the time spent for the user id and group by user id.
For example you can use it
realations = Entry.where(user_id: [1, 2, 3]).select("SUM(time_spent) as total_spent").group(:user_id)
After that you have relation with which you can work
realations.each do |i|
puts i.total_spent
end

How to get shipping address in new column of order list in xcart

I am newbie in X Cart and working on XCart 5.2.5. I would like to know that how can I displays customer billing or shipping address in one new custom column of order list at back end.
Please see the attached screen shots below
Order list screenshot
Any kind of help will be appreciated.
You would need to decorate the \XLite\View\ItemsList\Model\Order\Admin\Search class and define a new column in the defineColumns() method.
The column definition should be something like this:
$columns['shipping_address'] = array(
static::COLUMN_NAME => 'Shipping address',
static::COLUMN_TEMPLATE => 'modules/Tony/OrderSearchChange/order/shipping_address/body.tpl',
static::COLUMN_ORDERBY => 350,
);
First field defines a title of the column, the second field defines a template that will be shown in the table's cell and the third one defines the position of the column (the higher the number the further to the left the column will be).
I have also created a sample module, so you could play with it:
https://dl.dropboxusercontent.com/u/23858825/Tony-OrderSearchChange-v5_2_0.tar
Tony

CakePHP find list with group name same as data name

I have to show a select box with the different movie genres grouped by general genres.
To do so, I'm using the CakePHP default method find('list',...).
My database table for movie genres is done like so:
|_id_|_name_________|_general_genre_|
| 1 | Action | Action |
| 2 | Martial arts | Action |
| .. | ............ | ............. |
The problem is that if the group has the same name as the data (e.g.: "Action") the data is not shown in benefit of the group name.
So my select box looks like:
Select a genre
- Action
- Martial arts
- ...
And what I would like is:
Select a genre
- Action
- Action
- Martial arts
- ...
Of course, the reason is, it's not possible to select a group item.
Thanks in advance!
Ok, after some more research I finaly get the answer.
This is an attribute to add to the Html->input() method. This attribute is showParents.
So, if you want to make a select box with groups and have, inside this group, items with the same name that this group, you have to do something like this:
Select the list with the groups:
$options = $this->TableName->find('list', array(
'fields' => array('id', 'name', 'group_name')
));
Show the select input:
$this->Html->input('InputId', array(
'type' => 'select',
'options' => $options,
'showParents' => true
));
Hope this can help ;)
This is expected behavior. Use the showParents option when generating the form element. The API even has an eg. for this case which you failed to check :)
You can override the default fields that a find('list') returns (which are the primary key and the displayField) by your own fields, by setting the $options['fields'] option. These can be more than two fields if you need to. This should come close to what you need:
$this->Genre->find('list', array(
'fields' => array('id', 'name', 'general_genre')
));
This will return an array like:
'Action' =>
1 => 'Action'
2 => 'Martial arts'
You should be able to use that in a dropdown.

Symfony2: How can I list table elements in a FormChoice, separating them by some property

Is there any way to fetch objets from the DB and list them by Category? I have a table Artist which have a Genre and each Genre have a Category, so when I'm choosing Genre at new Artist creation I would like to see them separately by each one Category. I recall that in previous versions you could do something like:
$this->widgetSchema['genre_id'] = new sfWidgetFormChoice(array(
'choices' => array('-- Select --',
'-- Category1 --'=>Doctrine_Core::getTable('Genre')->getGenres('Category1')),
'-- Category2 --'=>Doctrine_Core::getTable('Genre')->getGenres('Category2')),
'multiple' => false, 'expanded' => false
));
And the result was a drop down with 'CategoryX' in bold, followed by respectively genres.
After a deep search all I've found is:
->add('group', 'entity', array(
'class' => 'Vendor\MyBundle\Entity\Group',
'label'=>'Group:',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('g')
->... // whatever you want to do
}
))
I think that is what I need, but have no idea on how to adapt it to what I'm looking for.
Many thanks.