Post by mdfarukh » Sun Dec 08, 2019 2:47 pm

I want to hide the "membership product" from shopping cart but customer can pay for "membership product". when customer click "buy now" button then redirect checkout page i have already done this process. but i can't hide the membership product from shopping cart. Thanks in advance.

Attachments

Shopping Cart.png

Shopping Cart.png (15.79 KiB) Viewed 43465 times


Newbie

Posts

Joined
Tue Nov 14, 2017 11:07 am

Post by thekrotek » Sun Dec 08, 2019 3:33 pm

If this product is available for certain customer only, you can add a modification, which will redirect other customers to the Cart page, when they add this product. It will work similar to the Minimum quantity requirement.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by by mona » Sun Dec 08, 2019 7:58 pm

If it is a specific product, you could get the product id and write the php to the shopping cart only to display if it is not that product id

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 mdfarukh » Mon Dec 09, 2019 1:53 pm

by mona wrote:
Sun Dec 08, 2019 7:58 pm
If it is a specific product, you could get the product id and write the php to the shopping cart only to display if it is not that product id
product id=50, product id=51, product id=53,
how to hide only this three products from cart, please help me..
This is my "controller/common/cart.php"

Code: Select all

<?php
class ControllerCommonCart extends Controller {
	public function index() {
		$this->load->language('common/cart');

		// Totals
		$this->load->model('setting/extension');

		$totals = array();
		$taxes = $this->cart->getTaxes();
		$total = 0;

		// Because __call can not keep var references so we put them into an array.
		$total_data = array(
			'totals' => &$totals,
			'taxes'  => &$taxes,
			'total'  => &$total
		);
			
		// Display prices
		if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
			$sort_order = array();

			$results = $this->model_setting_extension->getExtensions('total');

			foreach ($results as $key => $value) {
				$sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order');
			}

			array_multisort($sort_order, SORT_ASC, $results);

			foreach ($results as $result) {
				if ($this->config->get('total_' . $result['code'] . '_status')) {
					$this->load->model('extension/total/' . $result['code']);

					// We have to put the totals in an array so that they pass by reference.
					$this->{'model_extension_total_' . $result['code']}->getTotal($total_data);
				}
			}

			$sort_order = array();

			foreach ($totals as $key => $value) {
				$sort_order[$key] = $value['sort_order'];
			}

			array_multisort($sort_order, SORT_ASC, $totals);
		}

		if($this->cart->countProducts() > 1) {

		$data['text_items'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), '');
		} else {

		$data['text_items'] = sprintf($this->language->get('text_item'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), '');
		}

		$data['text_items_small'] = $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0);

		$this->load->model('tool/image');
		$this->load->model('tool/upload');

		$data['products'] = array();

		foreach ($this->cart->getProducts() as $product) {
			if ($product['image']) {
				$image = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_height'));
			} else {
				$image = '';
			}

			$option_data = array();

			foreach ($product['option'] as $option) {
				if ($option['type'] != 'file') {
					$value = $option['value'];
				} else {
					$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);

					if ($upload_info) {
						$value = $upload_info['name'];
					} else {
						$value = '';
					}
				}

				$option_data[] = array(
					'name'  => $option['name'],
					'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value),
					'type'  => $option['type']
				);
			}
			
			// Display prices
			if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
				$unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'));
				
				$price = $this->currency->format($unit_price, $this->session->data['currency']);
				$total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']);
			} else {
				$price = false;
				$total = false;
			}

			$data['products'][] = array(
				'cart_id'   => $product['cart_id'],
				'thumb'     => $image,
				'name'      => $product['name'],
				'model'     => $product['model'],
				'option'    => $option_data,
				'recurring' => ($product['recurring'] ? $product['recurring']['name'] : ''),
				'quantity'  => $product['quantity'],
				'price'     => $price,
				'total'     => $total,
				'href'      => $this->url->link('product/product', 'product_id=' . $product['product_id'])
			);
		}
		

		// Gift Voucher
		$data['vouchers'] = array();

		if (!empty($this->session->data['vouchers'])) {
			foreach ($this->session->data['vouchers'] as $key => $voucher) {
				$data['vouchers'][] = array(
					'key'         => $key,
					'description' => $voucher['description'],
					'amount'      => $this->currency->format($voucher['amount'], $this->session->data['currency'])
				);
			}
		}

		$data['totals'] = array();

		foreach ($totals as $total) {
			$data['totals'][] = array(
				'title' => $total['title'],
				'text'  => $this->currency->format($total['value'], $this->session->data['currency']),
			);
		}

		$data['cart'] = $this->url->link('checkout/cart');
		$data['checkout'] = $this->url->link('checkout/checkout', '', true);
		
		
		
		
		
		
		
		
/*
		$products = $this->model_catalog_product->getProducts($product_id);
        foreach($products as $product) { 
           if($product['product_id'] == 50 || $product['product_id'] == 51 || $product['product_id'] == 53) { 


            } else { 
             
             
            } 
         } 
*/
		
		
		
		
		
		
		
		
		

		return $this->load->view('common/cart', $data);
	}

	public function info() {
		$this->response->setOutput($this->index());
	}
}

Newbie

Posts

Joined
Tue Nov 14, 2017 11:07 am

Post by by mona » Mon Dec 09, 2019 9:41 pm

Hi,
I believe this to be beyond the scope of support. It is not a difficult job, but it does require knowledge and time.

Maybe this link might help you to search google to learn how to do this yourself.
https://stackoverflow.com/questions/238 ... y-this-div

and php to twig
https://twig.symfony.com/doc/3.x/tags/if.html

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 mdfarukh » Tue Dec 10, 2019 1:18 pm

by mona wrote:
Mon Dec 09, 2019 9:41 pm
Hi,
I believe this to be beyond the scope of support. It is not a difficult job, but it does require knowledge and time.

Maybe this link might help you to search google to learn how to do this yourself.
https://stackoverflow.com/questions/238 ... y-this-div

and php to twig
https://twig.symfony.com/doc/3.x/tags/if.html

Actually i am a beginner of php and i have no idea of opencart 3 but other work i have already done and I'm stuck in this position. so please do something for me and really really i need your help for my project. Thanks in advance.

Newbie

Posts

Joined
Tue Nov 14, 2017 11:07 am

Post by by mona » Wed Dec 11, 2019 12:14 pm

Replied ..

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 20 guests