Post by clivem » Thu Feb 02, 2023 5:07 am

Looking for someone who can help me create this for my store.

Opencart only has 2 options or Triggers rather for showing stock statuses :
+ve values of stock as in stock, or Zero or -ve values as out of stock. yes i can edit the out of stock status to show anything i want but i need a 3rd trigger rather.

I want a third trigger - i want to be able to enter a value of -1 and for the status to then be Pre-order

I also then want to be able to allow Store checkout when values are negative ( as they will now be on pre-order) . My store as default is set to not allow checkout on out of stock items as i dont want people buying out of stock items. However when i know i am getting specific items in i can set the value to -1 and set it to pre-order, then and only then will it again allow store checkout.

so for example

value 1 or higher - IN STOCK ( and this will allow store checkout)
Value 0 - OUT OF STOCK ( and no store checkout is allowed)
Value -1 or lower ( PRE_ORDER) and store checkout is allowed)

Lastly the ability to have the pre-order able to be set at a discounted rate by % could also be useful.

All pre-orders can then be set by me by choosing each product i need by setting the value to -1

New member

Posts

Joined
Mon Jun 12, 2017 8:18 pm

Post by by mona » Thu Feb 02, 2023 11:56 am

clivem wrote:
Thu Feb 02, 2023 5:07 am
Opencart only has 2 options or Triggers rather for showing stock statuses :
You can add any shop status in the back end system => localisation => stock status
here you can add pre-order - since it is coming into stock you can add the stock that is coming in


clivem wrote:
Thu Feb 02, 2023 5:07 am
I want a third trigger - i want to be able to enter a value of -1 and for the status to then be Pre-order
This can be done in the catalog/controller/catalog/product.php
a crude but easy to follow quick example
from

Code: Select all

                       if ($product_info['quantity'] <= 0) {
				$data['stock'] = $product_info['stock_status'];
			} elseif ($this->config->get('config_stock_display')) {
				$data['stock'] = $product_info['quantity'];
			} else {
				$data['stock'] = $this->language->get('text_instock');
			}
to

Code: Select all

                      if ($product_info['quantity'] == 0) {
				$data['stock'] = $product_info['stock_status'];
			} elseif($product_info['quantity'] < 0) {
				$data['stock'] = 'PRE-ORDER';
			} elseif ($this->config->get('config_stock_display')) {
				$data['stock'] = $product_info['quantity'];
			} else {
				$data['stock'] = $this->language->get('text_instock');
			}


clivem wrote:
Thu Feb 02, 2023 5:07 am
value 1 or higher - IN STOCK ( and this will allow store checkout)
Value 0 - OUT OF STOCK ( and no store checkout is allowed)
Value -1 or lower ( PRE_ORDER) and store checkout is allowed)
If you add a Pre-Order status then this will not be a problem as there will be stock.
If you insist on -1 stock then yes that will have to be written, but I don’t think you realise that you can add a stock status.


clivem wrote:
Thu Feb 02, 2023 5:07 am
Lastly the ability to have the pre-order able to be set at a discounted rate by % could also be useful.
That again can be done via the admin per product, but I assume you mean automatically
20% discount (assuming you use a pre_order status)
again catalog/controller/catalog/product.php and not very pretty but as an example
change

Code: Select all

			if ((float)$product_info['special']) {
				$data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
			} else {
				$data['special'] = false;
			}
for

Code: Select all

                        if($product_info['stock_status'] == 8 ) {  // where the stock status_id for pre-order is 8             
				$data['special'] = $this->currency->format($this->tax->calculate( ($product_info['price'] * .8), $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
			} elseif ((float)$product_info['special']) {
				$data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
			} else {
				$data['special'] = false;
			}

clivem wrote:
Thu Feb 02, 2023 5:07 am
All pre-orders can then be set by me by choosing each product i need by setting the value to -1
So there seems to me not to be an issue adding a new status rather than 'recreating the wheel' so to speak.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by clivem » Thu Feb 02, 2023 8:03 pm

by mona wrote:
Thu Feb 02, 2023 11:56 am
clivem wrote:
Thu Feb 02, 2023 5:07 am
Opencart only has 2 options or Triggers rather for showing stock statuses :
You can add any shop status in the back end system => localisation => stock status
here you can add pre-order - since it is coming into stock you can add the stock that is coming in
[/quote]

Mona, thanks so much for the reply! i will go though more detail later.
Yes i can edit back end system => localisation => stock status
here you can add pre-order, but there is only 1 trigger for when you add stock qty, it will always then show 'In Stock'
i cannot choose to say Pre-order while the site shows we have stock, only when the site is 0 or less then the 'out of stock' status is shown which can be of course anything i want.....

New member

Posts

Joined
Mon Jun 12, 2017 8:18 pm

Post by by mona » Thu Feb 02, 2023 8:34 pm

ok

Code: Select all

			if ($product_info['quantity'] == 987654) {
				$data['stock'] = 'PRE-ORDER';
			} elseif ($product_info['quantity'] <= 0) {
				$data['stock'] = $product_info['stock_status'];
			} elseif ($this->config->get('config_stock_display')) {
				$data['stock'] = $product_info['quantity'];
			} else {
				$data['stock'] = $this->language->get('text_instock');
			}

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by clivem » Thu Feb 02, 2023 11:20 pm

Mona,

thanks! i have changed it a bit to work like i wanted with -ve numbers Like the below. the only issue is I now need Stock checkout to be enabled at stock above ZERO, no store checkout if stock is ZERO, and again to allow store checkout when stock is less than ZERO!

the reason not to use ==987654 is that as soon as 1 customer places an order it will go back to 'In stock' when actually its not in stock. i could allow for a range of numbers between 999 and 899 for example ....... but i feel easier to use negative numbers for me as i know that is the pre-order stock numbers

then i will be all sorted :)
if ($product_info['quantity'] <= -1) {
$data['stock'] = 'PRE-ORDER';
} elseif ($product_info['quantity'] == 0) {
$data['stock'] = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$data['stock'] = $product_info['quantity'];
} else {
$data['stock'] = $this->language->get('text_instock');
}

New member

Posts

Joined
Mon Jun 12, 2017 8:18 pm

Post by clivem » Fri Feb 03, 2023 3:12 am

PS...... Mona,

if you can write modification i set core files back to original - and very happy to buy you coffee! :banana:

New member

Posts

Joined
Mon Jun 12, 2017 8:18 pm

Post by by mona » Sat Feb 04, 2023 3:11 am

Sent you message

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 13 guests