Ubercart sales planning

Contrib type: 
Module
Status: 
Initial upload
Moderation: 
Awaiting moderation

Downloads

Latest version: 
6x-1.0_alpha
Compatibility: 
Ubercart 2.x

The module is called uc_sales_planning,
it provides forms elements and logic to enable and plan sales on you store based on ubercart.
That means that you will be able to set a different price for products or product classes
and to choose the period of time when this has to be set instead of the standard "sell price" provided by ubercart.
Basically you might choose to set a sale planning on the product class, configuring it in the
content type admin page and then overwriting this configuration in the node add/edit page for the
single product or you might plan sales for the single products only, it depends on your commercial policy.
The per product settings overwrite the node type settings when a sale planning is activated on the
add/edit node page while you're still able to exclude a single product from a sale set for the content type
simply enabling the relative checkbox.
The module will then work with the standard cart block provided by ubercart, it just adds some infos when a selected product is on sale, showing the sale price and the previous price to inform the user about the discount applied.
The module will also alter the cart page table, showing sales info in a new column when needed and the same happens for the checkout page in the cart review box.
You have the chance to export your content types settings with features and strongarm if you use them, you can also use some actions provided by the module to make batch operations on the node's settings using views bulk operations, the module has a basic integration with views, it provides a field for the sale price, indeed.

The module uses date_popup as a widget for date field insertion so it is required as well as jquery_ui even though date_popup will install without working if it is not enabled.

The world of plugins for ubercart working as discount frameworks or specific solutions to set discount policies is very large, but at the same time i couldn't find a module made to plan sales for product and product classes and i think it is an important feature for an e-commerce software.
I've tried uc_discount, uc_discount_alt, uc_custom_price, uc_lto with no luck before attempting to write uc_sales_planning.
My work has to give some credit to uc_lto, i started from there, indeed.
Thanks,
Da.


PreviewAttachmentSize
uc_sales_planning.zip41.75 KB
dainis's picture
Offline
Joined: 12/14/2010
Juice: 32
Re: Ubercart sales planning

Hi. I test this module and it works great. It do what it must do. I use it together with marketplace module, and it work also, each seller can choose to add discount to product or not.
I would like to ask only few questions:
How it is possible to add block with all products on sale. Cam you please tell what it Views configurations?
And second, I would like to know is it possible to add below price time till when discount will be able. Is it possible?

Thanks you for excellent module Smiling

planctus's picture
Offline
Joined: 12/13/2010
Juice: 21
Hi Dainis, you can't have a

Hi Dainis,
you can't have a block with discounted products right now, even though it wouldn't require lot of effort to add this feature.
The problem is that the views integration is quite rude, you only have a field called "sale price" that you might use, but it will show the sale price set for that node without checking if it is "active" or not, so it is pretty useless as of now.
I might build a configurable block directly in the module, anyway.

A useful feature instead would be using action together with views bulk operation, that way you can set or change sales planning for many nodes ad the same time without having to edit the nodes and this is already working but that's a different story.

You're certanly able to show the expiration date for a planned sale, you have the chance to do this while using the node->content if you enable the "show additional infos" in the sales planning fieldset in the content type admin page, find the right checkbox and this way you will see a container with some infos about the sale in the node content.
There's is themable function that you might use to change the infos showed inside this box, too.

I'm not working on the module in this moment but i will probably do something in the next weeks, i think i will add the block you were asking and i will try to integrate the module with uc_discounts_alt module so i guess i will leave the views integration improvement for future development.
See you,
Da.

franso's picture
Offline
Joined: 10/18/2010
Juice: 15
problem with tax

Thank you for this great module. I am using it on my website but now I can see that I have one problem with the VAT module
that I am using for the tax rates.

Here is an example:

I have a product that cost 4.000 kr. inclusive taxes 25.5% and my sale price is 3.000 kr.
But when I click on save the previous price is 3.187 kr. exclusive taxes and not 4.000 kr. like it should be.

Is there something that I can do to fix this.

Thanks,
Franz

franso's picture
Offline
Joined: 10/18/2010
Juice: 15
<del>

There is also one more thing that I have noticed.
When I am using views to display the products <del> is not added to the previous price like on the node page.

Thanks,
Franz

planctus's picture
Offline
Joined: 12/13/2010
Juice: 21
Re: <del>

I've never tested the module with VAT so i guess it should need some code to make it work with it, i promise i will take a look but i don't know when i will.
For now, i suspect the module would not work correctly while using VAT.
As i already said, the views support is really rude for now, you only have the field but it won't affect anything else and it won't be aware about the time slot when it is supposed to activate so my advice is not to use it until it will be improved.
I'll see what i can do in the next days but i'm not planning to work on the views integration as the next step on the roadmap.
See you,
Da.

deardagny's picture
Offline
Joined: 02/06/2011
Juice: 13
Custom .tpl

So glad I found this – suits my needs perfectly! Quick question though:

I'm guessing it's simple, but I'm using a custom product.tpl and I'd like to include the "extra information" div, but I'm not quite sure how. Could you give me a quick idea of what needs to be in my .tpl file so that this info is included when the option is enabled? Thanks!

planctus's picture
Offline
Joined: 12/13/2010
Juice: 21
Printing the extra infos inside the node.tpl.php

Well, it is quite easy...but it's your choice how to do that:
You might do this way:
when the product is on sale you have this block of informations in node->content.
If you don't print out all the content array, you can show the additional infos simply adding

<?php print $node->content['uc_sales_planning']['#value']; ?>

Remember that this is built by a themable function that you might want to override to change all the infos in the block, to do this you simply add in your template.php a function like this:

function yourthemename_uc_sales_planning_show_more($node) {
  drupal_add_css(drupal_get_path('module', 'uc_sales_planning') . '/css/uc_sales_planning.css');
  $weight = content_extra_field_weight($node->type, 'uc_sales_planning');
  $discount = $node->discount_percent ? '<span>with the<strong> '. $node->discount_percent .'</strong>% sale</span>' : NULL;
  $output = '<div class="uc_sales_planning">
                      <h3>'. t('This product is on sale!') .'</h3>
                        <p>Its normal price is: <del>'. uc_currency_format($node->sell_price) .'</del></p>
                        <p>but you can buy it for just:<strong>'. uc_currency_format($node->sale_price) .'</strong> '. $discount .'</p>
                        <p>Until: <strong>'. format_date($node->expiration,  'custom', 'l, j F Y') .'</strong>
                        at '. format_date($node->expiration,  'custom', 'h:i') .'</p>
                        <p>Don\'t miss it!</p>
                  </div>';
  return $output;
}

This is the way the module formats the info in the additional infos block.

But you also have a different way to print info about the sale, and you could test the extra variable provided by the module to ensure the product is on sale:

<?php if($node->on_sale) :?>
Then you can do whatever you'd like, consider that you have some variables inside the $node object like:

$node->activation; $node->expiration, $node->sale_price

You also have

$node->discount_percent

when the sale is set on the product class.

So, this is up to you, hope you won't have problems doing this.
See you,
Da.

deardagny's picture
Offline
Joined: 02/06/2011
Juice: 13
Perfect

Thanks for the help. I appreciate it!

deardagny's picture
Offline
Joined: 02/06/2011
Juice: 13
One more issue

I've got everything displaying the way I want using my custom .tpl, but in trying to add the sale prices to a view, the "sale price" field is not returning any prices. Actually, the one product on which I'm getting a sale price is the only product on which I used node specific settings to shut off the sale (in this case, the original price is also returned as the sale price). I noticed you mentioned above that the sale price field isn't behaving correctly, but I was hoping if I could at least return the right prices I'd be able to use some custom php to display the way I want. Any ideas?

Thanks again.

planctus's picture
Offline
Joined: 12/13/2010
Juice: 21
i'll try to replicate this.

Ok, i think i got it:
You set a planning for a product class, then you overwrote it for a specific node.
Now you would like to show the sale price in a view for that node and it doesn't appear or, worst, it overwrites the normal ubercart sell price.
Is that right?

The problem is that i'm not using this module in any website so i did just a few tests on it in the past but i guess it would need more.
The views field is pretty stupid, actually, it would just return the sale price without being consistent with the planned sale, i mean that if you have an inactive policy it would return the sale price in any case.
But i must understand better what you're trying to do in order to help you, even though i must also warn you about using the views field to do that because, as i said, there's no logic in the way the module return values from a view. Everything happens when loading a node and i did not test what happens when this is made by views.
You could alway choose "node" as the row style and if you use the build_mode module you can have the same results but having the $node object always available where you might handle what happens safely.

I'd like to spend some time on the module to improve it a little bit but as of now i'm pretty busy so i'm not sure i can do this quickly.
Thanks,
Da.

planctus's picture
Offline
Joined: 12/13/2010
Juice: 21
Re: i'll try to replicate this.

Basically i can't see an easy way to really improve the views integration for this module.
Views is about retrieving information from the database and sometimes we have nothing to retrieve, think about a sale planned for a product class, there isn't any "sale price" on the db, the price is calculated on the fly basing on the percent set.
On top of that, there are many situations where the value from the database would not make any sense if the plan is not active.
Even if we had that value we should check if it's active or not, you might have set a sale price that it's not "active" anymore but the handler doesn't know anything about that.
So, i think the views field is pretty useless, it has been just a little challenge to see what was needed in order to build a views field, but it is misleading and i should remove it.

You have to use the information i gave you before, even using views you can use them if you choose node as the row field, and i think that is the best thing to do.
See you,
Da.

deardagny's picture
Offline
Joined: 02/06/2011
Juice: 13
Re: Re: i'll try to replicate this.

Thanks Da. This all makes sense now – I was mistakenly thinking that the sale prices were being added to the db. I'll just have to use the node row type and modify the display with another custom tpl. Thanks again for your quick responses – you've been a huge help!

maksim24's picture
Offline
Joined: 10/25/2010
Juice: 25
Bulk operation

Thanks for your module. but I have some question. I installed the views_bulk_operations module and I am trying to set sales planning on nodes.
On the bulk operation page:
1. choose update the sales period of your products
2. select nodes
3. click Execute.
4. set Activation date and Expiration date & time.
But where I can input the price %?
I want create sales plan on one days and set price %.
thanks for your answer.

maksim24's picture
Offline
Joined: 10/25/2010
Juice: 25
create action

I created small module with action: Update the sale price of your products and using it with views_bulk_operation

maksim24's picture
Offline
Joined: 10/25/2010
Juice: 25
Expiration date

What do you think about records that is still in the database where expiration date is expired. May be we should delete those records?
About views. Can i use the expiration date in views?

planctus's picture
Offline
Joined: 12/13/2010
Juice: 21
Re: Ubercart sales planning

I don't know, i think that if you planned some sales for a product or a product class you would like to see when it was set, even if it is not more active, maybe to renew it on the next year or season.
There's not a crucial reason to erase those records, indeed but i guess it could be an option for the user whether to erase the data or not after the expiration.
Could you simply write an action instead of a complete module for the sale price update, then? I would add it to the sales_planning module, indeed.
thanks,
Da.

maksim24's picture
Offline
Joined: 10/25/2010
Juice: 25
add to module

I attached the module where i added action and some views data if you add this code in uc_sales_products this will be very nice (Sorry for my english)
but i have another problem. If your sales planning date is over but state is active you will get two product price in your cart.

AttachmentSize
uc_sales_planning_ac.zip 3.01 KB
maksim24's picture
Offline
Joined: 10/25/2010
Juice: 25
theme price

in the uc_sale_planning.module is not correct run theme function

$node->content['sell_price']['#value'] = theme_uc_sales_planning_sell_price($node->sell_price, $node->sale_price);
$node->content['display_price']['#value']=  theme_uc_sales_planning_display_price($node->sell_price, $node->sale_price);

need to change to

$node->content['sell_price']['#value'] = theme('uc_sales_planning_sell_price', $node->sell_price, $node->sale_price);
$node->content['display_price']['#value']=  theme('uc_sales_planning_display_price', $node->sell_price, $node->sale_price);

and add information about theme function

/**
* Implementation of hook_theme().
*/
function uc_sales_planning_theme() {

return array(
    'uc_sales_planning_sell_price' => array(
      'arguments' => array( 'sell', 'sale' ),
    ),
    'uc_sales_planning_display_price' => array(
      'arguments' => array( 'sell', 'sale' ),
    ),

);
}